• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BitcoinURI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.bitcoin.uri.BitcoinURI的典型用法代码示例。如果您正苦于以下问题:Java BitcoinURI类的具体用法?Java BitcoinURI怎么用?Java BitcoinURI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BitcoinURI类属于com.google.bitcoin.uri包,在下文中一共展示了BitcoinURI类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: determineRequestStr

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
private String determineRequestStr(final boolean includeBluetoothMac)
{
	final boolean includeLabel = includeLabelView.isChecked();

	final ECKey key = (ECKey) addressView.getSelectedItem();
	final Address address = key.toAddress(Constants.NETWORK_PARAMETERS);
	final String label = includeLabel ? AddressBookProvider.resolveLabel(activity, address.toString()) : null;
	final BigInteger amount = amountCalculatorLink.getAmount();

	final StringBuilder uri = new StringBuilder(BitcoinURI.convertToBitcoinURI(address, amount, label, null));
	if (includeBluetoothMac && bluetoothMac != null)
	{
		uri.append(amount == null && label == null ? '?' : '&');
		uri.append(Bluetooth.MAC_URI_PARAM).append('=').append(bluetoothMac);
	}
	return uri.toString();
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:18,代码来源:RequestCoinsFragment.java


示例2: updateView

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
private void updateView() {
	final Address selectedAddress = application.determineSelectedAddress();

	if (!selectedAddress.equals(lastSelectedAddress)) {
		lastSelectedAddress = selectedAddress;

		Editable dispAddress = WalletUtils.formatAddress(selectedAddress,
				Constants.ADDRESS_FORMAT_GROUP_SIZE,
				Constants.ADDRESS_FORMAT_LINE_SIZE);

		Log.d("disp address", dispAddress.toString());

		bitcoinAddressLabel.setText(dispAddress);

		final String addressStr = BitcoinURI.convertToBitcoinURI(
				selectedAddress, null, null, null);

		final int size = (int) (256 * getResources().getDisplayMetrics().density);
		qrCodeBitmap = Qr.bitmap(addressStr, size);
		bitcoinAddressQrView.setImageBitmap(qrCodeBitmap);

		Nfc.publishUri(nfcManager, getActivity(), addressStr);
	}
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:25,代码来源:WalletAddressFragment.java


示例3: createFromBitcoinUri

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:22,代码来源:PaymentSession.java


示例4: clearReceive

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
private void clearReceive()	{
    	edAddress.setText("");
        edAddress.setHint(R.string.request_payment_hint);
      	edAmount1.setText("");
      	if(isBTC) {
          	edAmount1.setHint("0.0000");
      	}
      	else {
          	edAmount1.setHint("0.00");
      	}
    	edAmount1.setText("0.0000");
    	
      	if(isBTC) {
          	tvAmount2.setText("0.00" + " " + strCurrentFiatCode);
      	}
      	else {
          	tvAmount2.setText("0.0000" + " BTC");
      	}

        tvAddress.setText("");
//        tvAddress.setVisibility(View.INVISIBLE);
        tvAddressBis.setText("");
//        tvAddressBis.setVisibility(View.INVISIBLE);
        
//        ivReceivingQR.setVisibility(View.INVISIBLE);
        
        currentSelectedAddress = defaultAddress;
        ivReceivingQR.setVisibility(View.VISIBLE);
        ivReceivingQR.setImageBitmap(generateQRCode(BitcoinURI.convertToBitcoinURI(currentSelectedAddress, BigInteger.ZERO, "", "")));
        String label = labels.get(currentSelectedAddress);
        String defaultDest = currentSelectedAddress;
        if(label != null) {
        	defaultDest = label;
        }
        tvAddress.setText(defaultDest);

        ivClearInput.setVisibility(View.INVISIBLE);
        icon_row.setVisibility(View.VISIBLE);

    }
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:41,代码来源:ReceiveFragment.java


示例5: createFromBitcoinUri

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
/**
 * 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 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, trustStoreLoader);
    } catch (URISyntaxException e) {
        throw new PaymentRequestException.InvalidPaymentRequestURL(e);
    }
}
 
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:21,代码来源:PaymentSession.java


示例6: main

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
public static void main(String[] args) throws PaymentRequestException,
		BitcoinURIParseException, InterruptedException, ExecutionException {

	String url = "bitcoin:13dbaDHdYUwDHP24Qg3fEa3yqCBWE5hd9y?amount=0.01&r=https%3A%2F%2Fbitpay.com%2Fi%2FT5P3671YhMuYsqbCt5LsPY";
	ListenableFuture<PaymentSession> future = null;
	if (url.startsWith("http")) {
		future = PaymentSession.createFromUrl(url);
	} else if (url.startsWith("bitcoin:")) {
		future = PaymentSession.createFromBitcoinUri(new BitcoinURI(url));
	}

	PaymentSession session = future.get(); // may throw
											// PaymentRequestException.
	
	System.out.println(session);
	
	String memo = session.getMemo();
	BigInteger amountWanted = session.getValue();
	PaymentRequest pr = session.getPaymentRequest();
	System.out.println(pr);
	System.out.println(session.getPaymentDetails());

	if (session.isExpired()) {
		System.out.println("session expired.");
	}

	PaymentSession.PkiVerificationData identity = null;
	try {
		identity = session.verifyPki();
		System.out.println(identity.name);
		System.out.println(identity.orgName);
		System.out.println(identity.rootAuthorityName);
	} catch (Exception e) {
		e.printStackTrace();
	}


}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:39,代码来源:BitcoinPaymentTool.java


示例7: uri

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
public String uri() {
    return BitcoinURI.convertToBitcoinURI(getAddress(), null, Main.APP_NAME, null);
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:4,代码来源:ClickableBitcoinAddress.java


示例8: showAddress

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
public void showAddress() {
    BTCFmt btcfmt = mBase.getBTCFmt();

    Address addr = mBase.getWalletService().nextReceiveAddress();
    String addrstr = addr.toString();

    TextView addrtv =
        (TextView) getActivity().findViewById(R.id.receive_addr);
    addrtv.setText(addrstr);
    addrtv.setVisibility(View.VISIBLE);

    String ss = mBTCAmountEditText.getText().toString();
    long bb = btcfmt.parse(ss.toString());
    BigInteger amt = bb == 0 ? null : BigInteger.valueOf(bb);

    String uri = BitcoinURI.convertToBitcoinURI(addrstr, amt, null, null);

    mLogger.info("view address uri=" + uri);

    final int size =
        (int) (240 * getResources().getDisplayMetrics().density);

    // Load the QR bitmap.
    Bitmap bm = createBitmap(uri, size);
    if (bm != null) {
        ImageView iv =
            (ImageView) getActivity().findViewById(R.id.receive_qr_view);
        iv.setImageBitmap(bm);
        iv.setVisibility(View.VISIBLE);
    }

    // Find the HDAddress object associated with this address.
    HDAddressDescription addrdesc =
        mBase.getWalletService().findAddress(addr);
    mHDAddress = addrdesc.hdAddress;
    mTransitioned = false;

    mFiatAmountEditText.setFocusable(false);
    mFiatAmountEditText.setFocusableInTouchMode(false);
    mBTCAmountEditText.setFocusable(false);
    mBTCAmountEditText.setFocusableInTouchMode(false);
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:43,代码来源:ReceiveFragment.java


示例9: handleShowQr

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
private void handleShowQr(final String address)
{
	final String uri = BitcoinURI.convertToBitcoinURI(address, null, null, null);
	final int size = (int) (256 * getResources().getDisplayMetrics().density);
	BitmapFragment.show(getFragmentManager(), Qr.bitmap(uri, size));
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:7,代码来源:SendingAddressesFragment.java


示例10: generateCoinSparkQRcode

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
/**
     * generate a QR code for coinspark asset transfer
     * @param address
     *            Coinspark address to show
     * @aram assetRef
     *		  Asset ref of asset, otherwise null for regular Bitcoin
     * @param amount
     *            amount of asset (in display units)
     * @param label
     *            label for swatch
     * @return
     */
    public BufferedImage generateCoinSparkQRcode(String address, String assetRef, String amount, String label, int scaleFactor) {
	//System.out.println(String.format("generateCoinSparkQRcode() invoked: address=%s, assetRef=%s, amount=%s, label=%s", address, assetRef, amount, label));
	String bitcoinURI = null;
	String qrAddress = null;
	CoinSparkAddress csa = CSMiscUtils.decodeCoinSparkAddress(address);
	if (csa != null) {
	    String btcAddress = CSMiscUtils.getBitcoinAddressStringFromCoinSparkAddress(csa);
	    if (btcAddress != null) {
		try {
		    if (btcAddress != null) {
			new Address(this.bitcoinController.getModel().getNetworkParameters(), btcAddress);
			qrAddress = address; // no exception, so valid coinspark (and btc) addrss
		    }
		} catch (AddressFormatException afe) {
		    // Bad underlying Bitcoin address, so return null from outer try catch
		    return null;
		} catch (java.lang.StringIndexOutOfBoundsException e) {
		    return null;
		}
	    }
	}
	
	if (qrAddress != null && !"".equals(qrAddress)) {

	    // If coinspark address, and asset ref is defined, than this is not bitcoin but a coinspark asset
	    if (assetRef != null && !"".equals(assetRef)) {
		label = "<CSAssetRef>" + assetRef + "</CSAssetRef>" + label;
		    // FIXME: For now, we use tags, unlikely to be also used by human in label
		//        and because we want to re-use BitcoinURI.java (for now)
	    }

	    if (amount != null && !"".equals(amount)) {
		    // FIXME: For now just use this code, in future we just want to keep display units as is.
		// or create biddecimal.
		CurrencyConverterResult converterResult = CurrencyConverter.INSTANCE.parseToBTCNotLocalised(amount);
		if (converterResult.isBtcMoneyValid()) {
		    bitcoinURI = BitcoinURI.convertToBitcoinURI(qrAddress, converterResult.getBtcMoney().getAmount().toBigInteger(), label, null);
		} else {
		    // No parsable amount - show nothing.  
		}
	    } else {
		bitcoinURI = BitcoinURI.convertToBitcoinURI(qrAddress, null, label, null);
	    }

	    // FIXME: Temporary fudge as we use BitcoinURI, we change scheme from Bitcoin to Coinspark
	    if (bitcoinURI != null) {
		bitcoinURI = bitcoinURI.replaceFirst("bitcoin:", "coinspark:");
	    }
	}
	this.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.SEND_PERFORM_PASTE_NOW, "false");

	if (bitcoinURI==null) return null;
	
//	System.out.println("coinspark bitcoinURI = " + bitcoinURI);

	return generateImageFromURI(bitcoinURI, scaleFactor);
    }
 
开发者ID:coinspark,项目名称:sparkbit,代码行数:70,代码来源:QRCodeGenerator.java


示例11: onCreate

import com.google.bitcoin.uri.BitcoinURI; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);

	setContentView(R.layout.activity_view_address);

       Intent intent = getIntent();
       mAddress = intent.getExtras().getString("address");
       mAmount = intent.getExtras().getLong("amount");

       BigInteger amt = mAmount == 0 ? null : BigInteger.valueOf(mAmount);

       mURI = BitcoinURI.convertToBitcoinURI(mAddress, amt, null, null);

       mLogger.info("view address uri=" + mURI);

       final int size =
           (int) (240 * getResources().getDisplayMetrics().density);

       Bitmap bm = createBitmap(mURI, size);
       if (bm != null) {
           ImageView iv = (ImageView) findViewById(R.id.address_qr_view);
           iv.setImageBitmap(bm);
       }

       TextView idtv = (TextView) findViewById(R.id.address);
       idtv.setText(mAddress);

       updateAmount();

       mLogger.info("ViewAddressActivity created");
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:34,代码来源:ViewAddressActivity.java



注:本文中的com.google.bitcoin.uri.BitcoinURI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OpenCameraInterface类代码示例发布时间:2022-05-21
下一篇:
Java PositionLengthAttribute类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap