Пример #1
0
  public boolean localSendCoins(Address a, double value) {
    BigInteger sendAmount = Craftcoinish.econ.inGameToBitcoin(value);

    Wallet.SendRequest request = Wallet.SendRequest.to(a, sendAmount);
    request.fee = minBitFee;

    if (!localWallet.completeTx(request)) return false;
    localPeerGroup.broadcastTransaction(request.tx);
    try {
      if (!localWallet.completeTx(request)) {
        return false;
      } else {
        localPeerGroup.broadcastTransaction(request.tx);
        try {
          localWallet.commitTx(request.tx);
        } catch (VerificationException e) {

        }
      }
    } catch (IllegalArgumentException x) {

    }
    Craftcoinish.log.warning("Sent transaction: " + request.tx.getHash());
    saveWallet();
    return true;
  }
Пример #2
0
  public boolean sendCoinsMulti(Map<Address, Double> toSend) {
    Transaction tx = new Transaction(Craftcoinish.network);
    double totalSend = 0.0;

    for (Entry<Address, Double> current : toSend.entrySet()) {
      totalSend += current.getValue() / Craftcoinish.mult;
      tx.addOutput(Craftcoinish.econ.inGameToBitcoin(current.getValue()), current.getKey());
    }

    if (totalSend < 0.01) {
      return false;
    }

    Wallet.SendRequest request = Wallet.SendRequest.forTx(tx);

    if (!localWallet.completeTx(request)) {
      return false;
    } else {
      localPeerGroup.broadcastTransaction(request.tx);
      try {
        localWallet.commitTx(request.tx);
      } catch (VerificationException e) {
        e.printStackTrace();
      }
      return true;
    }
  }