コード例 #1
0
  @Override
  public Transaction signTransaction(UnsignedTransaction unsigned, KeyCipher cipher)
      throws InvalidKeyCipher {
    checkNotArchived();
    if (!isValidEncryptionKey(cipher)) {
      throw new InvalidKeyCipher();
    }
    // Make all signatures, this is the CPU intensive part
    List<byte[]> signatures =
        StandardTransactionBuilder.generateSignatures(
            unsigned.getSignatureInfo(), new PrivateKeyRing(cipher));

    // Apply signatures and finalize transaction
    Transaction transaction = StandardTransactionBuilder.finalizeTransaction(unsigned, signatures);
    return transaction;
  }
コード例 #2
0
  public static Transaction createSignedTransaction(TradeSession ts, MbwManager mbwManager) {
    Preconditions.checkNotNull(ts.buyerAddress);

    // Create default wallet
    Wallet wallet = mbwManager.getRecordManager().getWallet(mbwManager.getWalletMode());

    // Get spendable outputs
    SpendableOutputs spendable =
        wallet.getLocalSpendableOutputs(mbwManager.getBlockChainAddressTracker());

    // Extract private key ring
    PrivateKeyRing keyRing = wallet.getPrivateKeyRing();

    // Create unsigned transaction
    UnsignedTransaction unsigned =
        createUnsignedTransaction(
            ts.satoshisFromSeller,
            ts.satoshisForBuyer,
            ts.buyerAddress,
            ts.feeAddress,
            mbwManager,
            spendable,
            keyRing,
            mbwManager.getNetwork());

    if (unsigned == null) {
      return null;
    }

    // Make signatures
    List<byte[]> signatures =
        StandardTransactionBuilder.generateSignatures(
            unsigned.getSignatureInfo(), keyRing, mbwManager.getRecordManager().getRandomSource());

    // Sign transaction
    Transaction tx = StandardTransactionBuilder.finalizeTransaction(unsigned, signatures);
    return tx;
  }