当前位置: 首页>>代码示例>>Java>>正文


Java ECKey.toAddress方法代码示例

本文整理汇总了Java中com.google.bitcoin.core.ECKey.toAddress方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.toAddress方法的具体用法?Java ECKey.toAddress怎么用?Java ECKey.toAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.bitcoin.core.ECKey的用法示例。


在下文中一共展示了ECKey.toAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: determineRequestStr

import com.google.bitcoin.core.ECKey; //导入方法依赖的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: HDAddress

import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
public HDAddress(NetworkParameters params,
                 DeterministicKey chainKey,
                 JSONObject addrNode)
    throws RuntimeException, JSONException {

    mParams = params;

    mAddrNum = addrNode.getInt("addrNum");
    mPath = addrNode.getString("path");

    // Derive ECKey.
    byte[] prvBytes = null;
    try {
        mPubBytes = Base58.decode(addrNode.getString("pubBytes"));
    } catch (AddressFormatException ex) {
        throw new RuntimeException("failed to decode pubBytes");
    }
    
    mECKey = new ECKey(prvBytes, mPubBytes);

    // Set creation time to BTCReceive epoch.
    mECKey.setCreationTimeSeconds(EPOCH);

    // Derive public key, public hash and address.
    mPubKey = mECKey.getPubKey();
    mPubKeyHash = mECKey.getPubKeyHash();
    mAddress = mECKey.toAddress(mParams);

    // Initialize transaction count and balance.  If we don't have
    // a persisted available amount, presume it is all available.
    mNumTrans = addrNode.getInt("numTrans");
    mBalance = addrNode.getLong("balance");
    mAvailable = addrNode.has("available") ?
        addrNode.getLong("available") : mBalance;

    mLogger.info("read address " + mPath + ": " + mAddress.toString());
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:38,代码来源:HDAddress.java

示例3: addChangeOutput

import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
private static void addChangeOutput(ECKey key, Transaction tx, List<TransactionOutPoint> unspents) throws Exception
{
    Coin fee        = Coin.valueOf(Constants.MIN_FEE);
    Coin in_coin    = totalInCoin(unspents);
    Coin out_coin   = totalOutCoin(tx);

    Coin total = Coin.ZERO.add(in_coin).subtract(out_coin).subtract(fee);

    String TAG = "BulletinBuilder";
    Log.d(TAG, "fee |" + fee.toString());
    Log.d(TAG, "in_coin |" + in_coin.toString());
    Log.d(TAG, "out_coin |" + out_coin.toString());
    Log.d(TAG, "total |" + total.toString());


    switch ( total.compareTo(Coin.ZERO) )
    {
        case  0:
        case  1:    break;
        case -1:    Log.d(TAG, Utils.bytesToHex(tx.bitcoinSerialize()) );
            throw new Exception("out_coin + fee exceeds in_coin | " + total.toString());
    }

    Coin min = Coin.valueOf( Constants.getStandardCoin() );
    Address default_addr = key.toAddress(Constants.NETWORK_PARAMETERS);

    while(total.compareTo(Coin.ZERO) == 1)
    {
        if(total.subtract(min).compareTo(min) >= 0)
        {
            tx.addOutput( new TransactionOutput(Constants.NETWORK_PARAMETERS, tx, min, default_addr) );
            total = total.subtract(min);
        }
        else
        {
            tx.addOutput( new TransactionOutput(Constants.NETWORK_PARAMETERS, tx, total, default_addr) );
            total = total.subtract(total);
        }
    }
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:41,代码来源:BulletinBuilder.java

示例4: updateFragments

import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
void updateFragments()
{
	final List<ECKey> keys = getWalletApplication().getWallet().getKeys();
	final ArrayList<Address> addresses = new ArrayList<Address>(keys.size());

	for (final ECKey key : keys)
	{
		final Address address = key.toAddress(Constants.NETWORK_PARAMETERS);
		addresses.add(address);
	}

	sendingAddressesFragment.setWalletAddresses(addresses);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:14,代码来源:AddressBookActivity.java

示例5: getView

import com.google.bitcoin.core.ECKey; //导入方法依赖的package包/类
@Override
public View getView(final int position, View row, final ViewGroup parent)
{
	final ECKey key = (ECKey) getItem(position);
	final Address address = key.toAddress(Constants.NETWORK_PARAMETERS);
	final boolean isRotateKey = wallet.isKeyRotating(key);

	if (row == null)
		row = inflater.inflate(R.layout.address_book_row, null);

	final boolean isDefaultAddress = address.toString().equals(selectedAddress);

	row.setBackgroundResource(isDefaultAddress ? R.color.bg_list_selected : R.color.bg_list);

	final TextView addressView = (TextView) row.findViewById(R.id.address_book_row_address);
	addressView.setText(WalletUtils.formatAddress(address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE));
	addressView.setTextColor(isRotateKey ? colorInsignificant : colorSignificant);

	final TextView labelView = (TextView) row.findViewById(R.id.address_book_row_label);
	final String label = AddressBookProvider.resolveLabel(context, address.toString());
	if (label != null)
	{
		labelView.setText(label);
		labelView.setTextColor(isRotateKey ? colorInsignificant : colorLessSignificant);
	}
	else
	{
		labelView.setText(R.string.address_unlabeled);
		labelView.setTextColor(colorInsignificant);
	}

	if (showKeyCreationTime)
	{
		final TextView createdView = (TextView) row.findViewById(R.id.address_book_row_created);
		final long createdMs = key.getCreationTimeSeconds() * DateUtils.SECOND_IN_MILLIS;
		if (createdMs != 0)
		{
			createdView.setText(dateFormat.format(new Date(createdMs)));
			createdView.setVisibility(View.VISIBLE);
		}
		else
		{
			createdView.setVisibility(View.GONE);
		}
	}

	final TextView messageView = (TextView) row.findViewById(R.id.address_book_row_message);
	messageView.setVisibility(isRotateKey ? View.VISIBLE : View.GONE);

	return row;
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:52,代码来源:WalletAddressesAdapter.java


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