本文整理了Java中org.bitcoinj.wallet.Wallet.sendCoinsOffline()
方法的一些代码示例,展示了Wallet.sendCoinsOffline()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wallet.sendCoinsOffline()
方法的具体详情如下:
包路径:org.bitcoinj.wallet.Wallet
类名称:Wallet
方法名:sendCoinsOffline
[英]Sends coins to the given address but does not broadcast the resulting pending transaction. It is still stored in the wallet, so when the wallet is added to a PeerGroup or Peer the transaction will be announced to the network. The given SendRequest is completed first using Wallet#completeTx(SendRequest) to make it valid.
[中]将硬币发送到给定地址,但不广播产生的未决交易。它仍然存储在钱包中,因此当钱包被添加到对等组或对等组时,交易将向网络宣布。首先使用Wallet#CompletEx(SendRequest)完成给定的SendRequest,使其生效。
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#currentChangeAddress()}.
* If an exception is thrown by {@link Peer#sendMessage(Message)} the transaction is still committed, so the
* pending transaction must be broadcast <b>by you</b> at some other time. Note that a fee may be automatically added
* if one may be required for the transaction to be confirmed.
*
* @return The {@link Transaction} that was created or null if there was insufficient balance to send the coins.
* @throws InsufficientMoneyException if the request could not be completed due to not enough balance.
* @throws IllegalArgumentException if you try and complete the same SendRequest twice
* @throws DustySendRequested if the resultant transaction would violate the dust rules.
* @throws CouldNotAdjustDownwards if emptying the wallet was requested and the output can't be shrunk for fees without violating a protocol rule.
* @throws ExceededMaxTransactionSize if the resultant transaction is too big for Bitcoin to process.
* @throws MultipleOpReturnRequested if there is more than one OP_RETURN output for the resultant transaction.
*/
public Transaction sendCoins(Peer peer, SendRequest request) throws InsufficientMoneyException {
Transaction tx = sendCoinsOffline(request);
peer.sendMessage(tx);
return tx;
}
代码示例来源:origin: HashEngineering/dashj
/**
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#currentChangeAddress()}.
* If an exception is thrown by {@link Peer#sendMessage(Message)} the transaction is still committed, so the
* pending transaction must be broadcast <b>by you</b> at some other time. Note that a fee may be automatically added
* if one may be required for the transaction to be confirmed.
*
* @return The {@link Transaction} that was created or null if there was insufficient balance to send the coins.
* @throws InsufficientMoneyException if the request could not be completed due to not enough balance.
* @throws IllegalArgumentException if you try and complete the same SendRequest twice
* @throws DustySendRequested if the resultant transaction would violate the dust rules.
* @throws CouldNotAdjustDownwards if emptying the wallet was requested and the output can't be shrunk for fees without violating a protocol rule.
* @throws ExceededMaxTransactionSize if the resultant transaction is too big for Bitcoin to process.
* @throws MultipleOpReturnRequested if there is more than one OP_RETURN output for the resultant transaction.
*/
public Transaction sendCoins(Peer peer, SendRequest request) throws InsufficientMoneyException {
Transaction tx = sendCoinsOffline(request);
peer.sendMessage(tx);
return tx;
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#currentChangeAddress()}.
* If an exception is thrown by {@link Peer#sendMessage(Message)} the transaction is still committed, so the
* pending transaction must be broadcast <b>by you</b> at some other time. Note that a fee may be automatically added
* if one may be required for the transaction to be confirmed.
*
* @return The {@link Transaction} that was created or null if there was insufficient balance to send the coins.
* @throws InsufficientMoneyException if the request could not be completed due to not enough balance.
* @throws IllegalArgumentException if you try and complete the same SendRequest twice
* @throws DustySendRequested if the resultant transaction would violate the dust rules.
* @throws CouldNotAdjustDownwards if emptying the wallet was requested and the output can't be shrunk for fees without violating a protocol rule.
* @throws ExceededMaxTransactionSize if the resultant transaction is too big for Bitcoin to process.
* @throws MultipleOpReturnRequested if there is more than one OP_RETURN output for the resultant transaction.
*/
public Transaction sendCoins(Peer peer, SendRequest request) throws InsufficientMoneyException {
Transaction tx = sendCoinsOffline(request);
peer.sendMessage(tx);
return tx;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#currentChangeAddress()}.
* If an exception is thrown by {@link Peer#sendMessage(Message)} the transaction is still committed, so the
* pending transaction must be broadcast <b>by you</b> at some other time. Note that a fee may be automatically added
* if one may be required for the transaction to be confirmed.
*
* @return The {@link Transaction} that was created or null if there was insufficient balance to send the coins.
* @throws InsufficientMoneyException if the request could not be completed due to not enough balance.
* @throws IllegalArgumentException if you try and complete the same SendRequest twice
* @throws DustySendRequested if the resultant transaction would violate the dust rules.
* @throws CouldNotAdjustDownwards if emptying the wallet was requested and the output can't be shrunk for fees without violating a protocol rule.
* @throws ExceededMaxTransactionSize if the resultant transaction is too big for Bitcoin to process.
* @throws MultipleOpReturnRequested if there is more than one OP_RETURN output for the resultant transaction.
*/
public Transaction sendCoins(Peer peer, SendRequest request) throws InsufficientMoneyException {
Transaction tx = sendCoinsOffline(request);
peer.sendMessage(tx);
return tx;
}
代码示例来源:origin: uncleleonfan/FunWallet
public void onSendBitcoin(View view) {
String to = mToAddressEdit.getText().toString();
String amount = mAmountEdit.getText().toString();
if (TextUtils.isEmpty(to) || TextUtils.isEmpty(amount)) {
return;
}
Address address = Address.fromBase58(Constants.NETWORK_PARAMETERS, to);
Coin coin = MonetaryFormat.MBTC.parse(amount);
SendRequest sendRequest = SendRequest.to(address, coin);
try {
Transaction transaction = wallet.sendCoinsOffline(sendRequest);
BlockChainService.broadcastTransaction(BitcoinWalletActivity.this, transaction);
} catch (InsufficientMoneyException e) {
Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
代码示例来源:origin: HashEngineering/dashj
Transaction tx = sendCoinsOffline(request);
SendResult result = new SendResult();
result.tx = tx;
代码示例来源:origin: greenaddress/GreenBits
Transaction tx = sendCoinsOffline(request);
SendResult result = new SendResult();
result.tx = tx;
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
Transaction tx = sendCoinsOffline(request);
SendResult result = new SendResult();
result.tx = tx;
代码示例来源:origin: fr.acinq/bitcoinj-core
Transaction tx = sendCoinsOffline(request);
SendResult result = new SendResult();
result.tx = tx;
代码示例来源:origin: greenaddress/GreenBits
@Test
public void importAndEncrypt() throws InsufficientMoneyException {
Wallet encryptedWallet = new Wallet(PARAMS);
encryptedWallet.encrypt(PASSWORD1);
final ECKey key = new ECKey();
encryptedWallet.importKeysAndEncrypt(ImmutableList.of(key), PASSWORD1);
assertEquals(1, encryptedWallet.getImportedKeys().size());
assertEquals(key.getPubKeyPoint(), encryptedWallet.getImportedKeys().get(0).getPubKeyPoint());
sendMoneyToWallet(encryptedWallet, AbstractBlockChain.NewBlockType.BEST_CHAIN, Coin.COIN, key.toAddress(PARAMS));
assertEquals(Coin.COIN, encryptedWallet.getBalance());
SendRequest req = SendRequest.emptyWallet(OTHER_ADDRESS);
req.aesKey = checkNotNull(encryptedWallet.getKeyCrypter()).deriveKey(PASSWORD1);
encryptedWallet.sendCoinsOffline(req);
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void feeSolverAndCoinSelectionTest_dustySendRequested() throws Exception {
// Generate a few outputs to us that are far too small to spend reasonably
Transaction tx1 = createFakeTx(PARAMS, SATOSHI, myAddress);
Transaction tx2 = createFakeTx(PARAMS, SATOSHI, myAddress);
assertNotEquals(tx1.getHash(), tx2.getHash());
Transaction tx3 = createFakeTx(PARAMS, SATOSHI.multiply(10), myAddress);
sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, tx1, tx2, tx3);
// Not allowed to send dust.
try {
SendRequest request = SendRequest.to(OTHER_ADDRESS, SATOSHI);
request.ensureMinRequiredFee = true;
wallet.completeTx(request);
fail();
} catch (Wallet.DustySendRequested e) {
// Expected.
}
// Spend it all without fee enforcement
SendRequest req = SendRequest.to(OTHER_ADDRESS, SATOSHI.multiply(12));
assertNotNull(wallet.sendCoinsOffline(req));
assertEquals(ZERO, wallet.getBalance());
}
代码示例来源:origin: greenaddress/GreenBits
Transaction spendCoinTx = wallet.sendCoinsOffline(SendRequest.to(new ECKey().toAddress(PARAMS), COIN));
assertEquals(Coin.ZERO, wallet.getBalance());
chain.add(makeSolvedTestBlock(blockStore.getChainHead().getHeader(), spendCoinTx, createFakeTx(PARAMS, CENT, myAddress)));
代码示例来源:origin: greenaddress/GreenBits
Transaction t3 = checkNotNull(wallet.sendCoinsOffline(req));
代码示例来源:origin: greenaddress/GreenBits
wallet.sendCoinsOffline(request);
assertEquals(Coin.ZERO, wallet.getBalance());
内容来源于网络,如有侵权,请联系作者删除!