コード例 #1
0
ファイル: PaymentSession.java プロジェクト: pavel4n/isracoinj
 /** Returns a {@link Wallet.SendRequest} suitable for broadcasting to the network. */
 public Wallet.SendRequest getSendRequest() {
   Transaction tx = new Transaction(params);
   for (Protos.Output output : paymentDetails.getOutputsList())
     tx.addOutput(
         new TransactionOutput(
             params,
             tx,
             BigInteger.valueOf(output.getAmount()),
             output.getScript().toByteArray()));
   return Wallet.SendRequest.forTx(tx);
 }
コード例 #2
0
ファイル: PaymentSession.java プロジェクト: pavel4n/isracoinj
 /**
  * Generates a Payment message based on the information in the PaymentRequest. Provide
  * transactions built by the wallet. If the PaymentRequest did not specify a payment_url, returns
  * null.
  *
  * @param txns list of transactions to be included with the Payment message.
  * @param refundAddr will be used by the merchant to send money back if there was a problem.
  * @param memo is a message to include in the payment message sent to the merchant.
  */
 public @Nullable Protos.Payment getPayment(
     List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
     throws IOException {
   if (!paymentDetails.hasPaymentUrl()) return null;
   Protos.Payment.Builder payment = Protos.Payment.newBuilder();
   if (paymentDetails.hasMerchantData()) payment.setMerchantData(paymentDetails.getMerchantData());
   if (refundAddr != null) {
     Protos.Output.Builder refundOutput = Protos.Output.newBuilder();
     refundOutput.setAmount(totalValue.longValue());
     refundOutput.setScript(
         ByteString.copyFrom(ScriptBuilder.createOutputScript(refundAddr).getProgram()));
     payment.addRefundTo(refundOutput);
   }
   if (memo != null) {
     payment.setMemo(memo);
   }
   for (Transaction txn : txns) {
     txn.verify();
     ByteArrayOutputStream o = new ByteArrayOutputStream();
     txn.bitcoinSerialize(o);
     payment.addTransactions(ByteString.copyFrom(o.toByteArray()));
   }
   return payment.build();
 }
コード例 #3
0
 public SendRequest toSendRequest() {
   final Transaction transaction = new Transaction(Constants.NETWORK_PARAMETERS);
   for (final PaymentIntent.Output output : outputs)
     transaction.addOutput(output.amount, output.script);
   return SendRequest.forTx(transaction);
 }