org.bitcoinj.uri.BitcoinURI Java Examples

The following examples show how to use org.bitcoinj.uri.BitcoinURI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReceiveFragment.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Bitmap doInBackground(final Object... integers) {
    final ReceiveFragment fragment = mFragment.get();
    if (fragment == null)
        return null;

    final String amount = UI.getText(fragment.mAmountEdit);
    fragment.mCurrentAmount = null;
    if (amount.isEmpty()) {
        if (fragment.mQrCodeBitmap == null)
            return null;
        return resetBitmap(fragment, fragment.mCurrentAddress);
    }

    try {
        final GaService service = fragment.getGAService();
        fragment.mCurrentAmount = UI.parseCoinValue(service, amount);

        final Address address = Address.fromBase58(service.getNetworkParameters(), fragment.mCurrentAddress);
        final String qrCodeText = BitcoinURI.convertToBitcoinURI(address, fragment.mCurrentAmount, null, null);
        return resetBitmap(fragment, qrCodeText);
    } catch (final ArithmeticException | IllegalArgumentException e) {
        return resetBitmap(fragment, fragment.mCurrentAddress);
    }
}
 
Example #2
Source File: PaymentSession.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 trustStoreLoader is null, the system default trust store is used.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki, @Nullable final TrustStoreLoader trustStoreLoader)
        throws PaymentProtocolException {
    String url = uri.getPaymentRequestUrl();
    if (url == null)
        throw new PaymentProtocolException.InvalidPaymentRequestURL("No payment request URL (r= parameter) in BitcoinURI " + uri);
    try {
        return fetchPaymentRequest(new URI(url), verifyPki, trustStoreLoader);
    } catch (URISyntaxException e) {
        throw new PaymentProtocolException.InvalidPaymentRequestURL(e);
    }
}
 
Example #3
Source File: PaymentSession.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 trustStoreLoader is null, the system default trust store is used.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki, @Nullable final TrustStoreLoader trustStoreLoader)
        throws PaymentProtocolException {
    String url = uri.getPaymentRequestUrl();
    if (url == null)
        throw new PaymentProtocolException.InvalidPaymentRequestURL("No payment request URL (r= parameter) in BitcoinURI " + uri);
    try {
        return fetchPaymentRequest(new URI(url), verifyPki, trustStoreLoader);
    } catch (URISyntaxException e) {
        throw new PaymentProtocolException.InvalidPaymentRequestURL(e);
    }
}
 
Example #4
Source File: ReceiveFragment.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
private String getAddressUri() {
    final String addr;
    final NetworkParameters params = getGAService().getNetworkParameters();
    if (getGAService().isElements())
        addr = ConfidentialAddress.fromBase58(params, mCurrentAddress).toString();
    else
        addr = Address.fromBase58(params, mCurrentAddress).toString();
    return BitcoinURI.convertToBitcoinURI(params, addr, mCurrentAmount, null, null);
}
 
Example #5
Source File: SendFragment.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
private void processBitcoinURI(final BitcoinURI URI, final String confidentialAddress, Coin amount) {
    if (URI != null && URI.getPaymentRequestUrl() != null) {
        processPaymentRequestUrl(URI.getPaymentRequestUrl());
        return;
    }
    final String address = URI == null ? null : URI.getAddress().toString();
    if (confidentialAddress == null)
        amount = URI.getAmount();
    processBitcoinURIDetails(address, confidentialAddress, amount);
}
 
Example #6
Source File: PaymentSession.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 trustStoreLoader is null, the system default trust store is used.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki, @Nullable final TrustStoreLoader trustStoreLoader)
        throws PaymentProtocolException {
    String url = uri.getPaymentRequestUrl();
    if (url == null)
        throw new PaymentProtocolException.InvalidPaymentRequestURL("No payment request URL (r= parameter) in BitcoinURI " + uri);
    try {
        return fetchPaymentRequest(new URI(url), verifyPki, trustStoreLoader);
    } catch (URISyntaxException e) {
        throw new PaymentProtocolException.InvalidPaymentRequestURL(e);
    }
}
 
Example #7
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public String uri() {
    return BitcoinURI.convertToBitcoinURI(address.get(), null, Main.APP_NAME, null);
}
 
Example #8
Source File: ClickableBitcoinAddress.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public String uri() {
    return BitcoinURI.convertToBitcoinURI(address.get(), null, Main.APP_NAME, null);
}
 
Example #9
Source File: ClickableBitcoinAddress.java    From devcoretalk with GNU General Public License v2.0 4 votes vote down vote up
public String uri() {
    return BitcoinURI.convertToBitcoinURI(address.get(), null, Main.APP_NAME, null);
}
 
Example #10
Source File: GUIUtil.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String getBitcoinURI(String address, Coin amount, String label) {
    return address != null ?
            BitcoinURI.convertToBitcoinURI(Address.fromBase58(Config.baseCurrencyNetworkParameters(),
                    address), amount, label, null) :
            "";
}
 
Example #11
Source File: PaymentSession.java    From bcm-android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 * <p>
 * <p>If 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.</p>
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri) throws PaymentProtocolException {
    return createFromBitcoinUri(uri, true, null);
}
 
Example #12
Source File: PaymentSession.java    From bcm-android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki)
        throws PaymentProtocolException {
    return createFromBitcoinUri(uri, verifyPki, null);
}
 
Example #13
Source File: PaymentSession.java    From green_android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>If 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.</p>
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri) throws PaymentProtocolException {
    return createFromBitcoinUri(uri, true, null);
}
 
Example #14
Source File: PaymentSession.java    From green_android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki)
        throws PaymentProtocolException {
    return createFromBitcoinUri(uri, verifyPki, null);
}
 
Example #15
Source File: PaymentSession.java    From GreenBits with GNU General Public License v3.0 2 votes vote down vote up
/**
 * <p>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.</p>
 *
 * <p>If 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.</p>
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri) throws PaymentProtocolException {
    return createFromBitcoinUri(uri, true, null);
}
 
Example #16
Source File: PaymentSession.java    From GreenBits with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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.
 */
public static ListenableFuture<PaymentSession> createFromBitcoinUri(final BitcoinURI uri, final boolean verifyPki)
        throws PaymentProtocolException {
    return createFromBitcoinUri(uri, verifyPki, null);
}