本文整理汇总了Java中org.bitcoinj.core.Coin.parseCoin方法的典型用法代码示例。如果您正苦于以下问题:Java Coin.parseCoin方法的具体用法?Java Coin.parseCoin怎么用?Java Coin.parseCoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.Coin
的用法示例。
在下文中一共展示了Coin.parseCoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.bitcoinj.core.Coin; //导入方法依赖的package包/类
/**
*
* @param callbacks
*/
@Override
public void execute(final CoinActionCallback<CurrencyCoin>... callbacks) {
this._callbacks = callbacks;
this._bitcoin.getWalletManager().wallet().addCoinsSentEventListener(this);
Coin balance = _bitcoin.getWalletManager().wallet().getBalance();
Coin amountCoin = Coin.parseCoin(_amount);
Address addr = Address.fromBase58(_bitcoin.getWalletManager().wallet().getParams(), _address);
SendRequest sendRequest = SendRequest.to(addr, amountCoin);
Coin feeCoin = BitcoinManager.CalculateFeeTxSizeBytes(sendRequest.tx, sendRequest.feePerKb.getValue());
long balValue = balance.getValue();
long amountValue = amountCoin.getValue();
long txFeeValue = feeCoin.getValue();
if (amountValue + txFeeValue > balValue) {
amountCoin = Coin.valueOf(balValue - txFeeValue);
sendRequest = SendRequest.to(addr, amountCoin);
}
try {
_bitcoin.getWalletManager().wallet().sendCoins(sendRequest);
} catch (InsufficientMoneyException e) {
for (CoinActionCallback<CurrencyCoin> callback : _callbacks) {
callback.onError(_bitcoin);
}
e.printStackTrace();
}
}
示例2: applyTxFee
import org.bitcoinj.core.Coin; //导入方法依赖的package包/类
/**
*
* @param valueMessage
* @return
*/
@Override
public SpentValueMessage applyTxFee(SpentValueMessage valueMessage) {
Coin amountCoin = Coin.parseCoin(valueMessage.getAmount());
Address addr = Address.fromBase58(_coin.getWalletManager().wallet().getParams(), valueMessage.getAddress());
SendRequest sendRequest = SendRequest.to(addr, amountCoin);
Coin txValue = CalculateFeeTxSizeBytes(sendRequest.tx, sendRequest.feePerKb.getValue());
valueMessage.setTxFee(txValue.toPlainString());
String amountStr = amountCoin.toPlainString();
valueMessage.setAmount(amountStr);
return valueMessage;
}