Skip to content

Commit 2837237

Browse files
committed
tapfreighter: unlock asset coins before err on tx broadcast fail
Ensure locked asset coins are released before returning an error when attempting to publish the anchor transaction. Without this change, if the chain bridge logic determines the anchor transaction should not be broadcast, the coins remain locked, leaving the send attempt stuck in limbo.
1 parent 1ff04d3 commit 2837237

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tapfreighter/chain_porter.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,18 @@ func (p *ChainPorter) stateStep(currentPkg sendPackage) (*sendPackage, error) {
13911391
"transaction %v: %w", txHash, err)
13921392

13931393
case err != nil:
1394+
// If the error is due to the min relay fee not being
1395+
// met, we'll unlock the inputs we locked for this
1396+
// transfer before returning the error.
1397+
if strings.Contains(
1398+
err.Error(), "min relay fee not met",
1399+
) {
1400+
p.unlockInputs(ctx, &currentPkg)
1401+
}
1402+
1403+
// We exercise caution by not unlocking the inputs in
1404+
// the general error case, in case the transaction was
1405+
// somehow broadcasted.
13941406
return nil, fmt.Errorf("unable to broadcast "+
13951407
"transaction %v: %w", txHash, err)
13961408
}

0 commit comments

Comments
 (0)