3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 06:44:16 +00:00

Handle the not-enough-funds case in sendCoinsAsync and sendCoins(PeerGroup ...). They got a NPE in this case during a recent refactoring. Resolves issue 136.

This commit is contained in:
Mike Hearn 2012-02-10 17:00:29 +01:00
parent 2d0891cf4b
commit 6597f01874

View File

@ -934,6 +934,8 @@ public class Wallet implements Serializable {
*/
public synchronized Transaction sendCoinsAsync(PeerGroup peerGroup, Address to, BigInteger nanocoins) throws IOException {
Transaction tx = sendCoinsOffline(to, nanocoins);
if (tx == null)
return null; // Not enough money.
// Just throw away the Future here. If the user wants it, they can call sendCoinsOffline/broadcastTransaction
// themselves.
peerGroup.broadcastTransaction(tx);
@ -951,6 +953,8 @@ public class Wallet implements Serializable {
*/
public synchronized Transaction sendCoins(PeerGroup peerGroup, Address to, BigInteger nanocoins) {
Transaction tx = sendCoinsOffline(to, nanocoins);
if (tx == null)
return null; // Not enough money.
try {
return peerGroup.broadcastTransaction(tx).get();
} catch (InterruptedException e) {