-
Notifications
You must be signed in to change notification settings - Fork 132
Unlock Coins on Anchor TX Broadcast Failure #1348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
043d19a
2b8c3f1
a562518
1ff04d3
2837237
cec657e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1178,6 +1178,9 @@ | |||
"minimum relay fee: %w", err) | ||||
} | ||||
|
||||
log.Infof("Min relay fee: %v", | ||||
minRelayFee.FeePerKVByte().String()) | ||||
|
||||
// If the fee rate is below the minimum relay fee, we'll | ||||
// bump it up. | ||||
if feeRate < minRelayFee { | ||||
|
@@ -1388,10 +1391,32 @@ | |||
"transaction %v: %w", txHash, err) | ||||
|
||||
case err != nil: | ||||
// If the error is due to the min relay fee not being | ||||
// met, we'll unlock the inputs we locked for this | ||||
// transfer before returning the error. | ||||
if strings.Contains( | ||||
err.Error(), "min relay fee not met", | ||||
) { | ||||
p.unlockInputs(ctx, ¤tPkg) | ||||
} | ||||
|
||||
// We exercise caution by not unlocking the inputs in | ||||
// the general error case, in case the transaction was | ||||
// somehow broadcasted. | ||||
return nil, fmt.Errorf("unable to broadcast "+ | ||||
"transaction %v: %w", txHash, err) | ||||
} | ||||
|
||||
// Set send state to the next state to evaluate. | ||||
currentPkg.SendState = SendStateBroadcastComplete | ||||
return ¤tPkg, nil | ||||
|
||||
// At this stage, the transaction has been broadcast to the network. | ||||
// From this point forward, the transfer cancellation methodology | ||||
// changes. | ||||
case SendStateBroadcastComplete: | ||||
log.Infof("Transfer tx broadcast complete") | ||||
|
||||
// With the transaction broadcast, we'll deliver a | ||||
// notification via the transaction broadcast response channel. | ||||
currentPkg.deliverTxBroadcastResp() | ||||
|
@@ -1466,6 +1491,9 @@ | |||
return | ||||
} | ||||
|
||||
// TODO(ffranr): Make use of CheckMempoolAccept to ensure we don't | ||||
// unlock inputs for transactions that are in the mempool. | ||||
|
||||
// If we haven't even attempted to broadcast yet, we're still in a state | ||||
// where we give feedback to the user synchronously, as we haven't | ||||
// created an on-chain transaction that we need to await confirmation. | ||||
|
@@ -1474,7 +1502,7 @@ | |||
// sanity-check that we have known input commitments to unlock, since | ||||
// that might not always be the case (for example if another party | ||||
// contributes inputs). | ||||
if pkg.SendState < SendStateStorePreBroadcast && | ||||
if pkg.SendState < SendStateBroadcastComplete && | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove the lease on assets when we are in state There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A similar problem occurs a few lines down (and wasn't introduced by this PR, but should still be handled) taproot-assets/tapfreighter/chain_porter.go Line 1520 in e0c9661
In states Also, we should inform the user what to do if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we should cleanup the pending parcel as well.
I don't think we currently call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, in the worst case, if we don't cancel the pending parcel then upon resumption, the asset coins would have been spent and the transaction would fail because the UTXO would have been spent. |
||||
len(pkg.InputCommitments) > 0 { | ||||
|
||||
for prevID := range pkg.InputCommitments { | ||||
|
@@ -1505,6 +1533,9 @@ | |||
log.Warnf("Unable to unlock input %v: %v", op, err) | ||||
} | ||||
} | ||||
|
||||
// TODO(ffranr): Remove pending asset transfer and chain tx from the | ||||
// database. | ||||
} | ||||
|
||||
// logPacket logs the virtual packet to the debug log. | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really elegant, adding this extra state here.