Skip to content

Commit

Permalink
Merge pull request #293 from rsksmart/fix_final_federation_retirement
Browse files Browse the repository at this point in the history
Prevent funds migration when there is no balance left
  • Loading branch information
aeidelman authored Dec 4, 2017
2 parents c29858b + 298690a commit 5dcba29
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,15 @@ public void updateCollections(Transaction rskTx) throws IOException {
}

if (retiringFederationWallet != null && activeFederationAge >= bridgeConstants.getFundsMigrationAgeEnd() && !pendingSignatures) {
BtcTransaction btcTx = createMigrationTransaction(retiringFederationWallet, getActiveFederation().getAddress());
provider.getRskTxsWaitingForSignatures().put(new Sha3Hash(rskTx.getHash()), btcTx);
if (retiringFederationWallet.getBalance().isGreaterThan(Coin.ZERO)) {
try {
BtcTransaction btcTx = createMigrationTransaction(retiringFederationWallet, getActiveFederation().getAddress());
provider.getRskTxsWaitingForSignatures().put(new Sha3Hash(rskTx.getHash()), btcTx);
} catch (Exception e) {
logger.error("Unable to complete retiring federation migration. Left balance: {} in {}", retiringFederationWallet.getBalance(), getRetiringFederationAddress());
panicProcessor.panic("updateCollection", "Unable to complete retiring federation migration.");
}
}
provider.setRetiringFederation(null);
}

Expand Down

0 comments on commit 5dcba29

Please sign in to comment.