public static PaymentIntent fromBitcoinUri(@Nonnull final BitcoinURI bitcoinUri) {
    final Output[] outputs = buildSimplePayTo(bitcoinUri.getAmount(), bitcoinUri.getAddress());
    final String bluetoothMac = (String) bitcoinUri.getParameterByName(Bluetooth.MAC_URI_PARAM);

    return new PaymentIntent(
        PaymentIntent.Standard.BIP21,
        null,
        null,
        outputs,
        bitcoinUri.getLabel(),
        bluetoothMac != null ? "bt:" + bluetoothMac : null,
        null,
        bitcoinUri.getPaymentRequestUrl());
  }
Пример #2
0
 /**
  * Returns a future that will be notified with a PaymentSession object after it is fetched using
  * the provided uri. uri is a BIP-72-style BitcoinURI object that specifies where the {@link
  * Protos.PaymentRequest} object may be fetched in the r= parameter. If verifyPki is specified and
  * the payment request object specifies a PKI method, then the system trust store will be used to
  * verify the signature provided by the payment request. An exception is thrown by the future if
  * the signature cannot be verified. If trustStorePath is not null, the trust store used for PKI
  * verification will be loaded from the given location instead of using the system default trust
  * store location.
  */
 public static ListenableFuture<PaymentSession> createFromBitcoinUri(
     final BitcoinURI uri, final boolean verifyPki, @Nullable final String trustStorePath)
     throws PaymentRequestException {
   String url = uri.getPaymentRequestUrl();
   if (url == null)
     throw new PaymentRequestException.InvalidPaymentRequestURL(
         "No payment request URL (r= parameter) in BitcoinURI " + uri);
   try {
     return fetchPaymentRequest(new URI(url), verifyPki, trustStorePath);
   } catch (URISyntaxException e) {
     throw new PaymentRequestException.InvalidPaymentRequestURL(e);
   }
 }