BTC re-order outputs of a signed transaction (detect change output reliably) #4596
-
|
Is there currently any supported way to reliably identify the change output index in WalletCore’s Bitcoin v2 signing output (as it stands today)? We have a case where, for certain transactions, we want to re-order outputs so that some “extra outputs” are always at the very end of the transaction. Today we set changeOutput on BitcoinSigningInput.signingV2.builder. In many cases the builder appends change at the end, but change is not guaranteed to exist (e.g. below dust / omitted), and the v2 signing output does not clearly label which output is change. As a result, clients can’t safely do outputs.last = change. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hi @dimitris-c, you can set the change manually in
|
Beta Was this translation helpful? Give feedback.
-
|
@satoshiotomakan Thanks for this, I missed that |
Beta Was this translation helpful? Give feedback.
-
|
Just out of curiosity do you have idea how a tx could result in having such a high fee? Fee is way too high, could be a result of misidentifying the change output but wouldn't WalletCore returned |
Beta Was this translation helpful? Give feedback.
Hi @dimitris-c, you can set the change manually in
Proto.TransactionBuilder.outputs. So the flow may look like:AnySigner.planwithProto.TransactionBuilder.outputsandProto.TransactionBuilder.changeOutputto get exact change amountProto.TransactionBuilder.changeOutputfrom the signing input, and push it back toProto.TransactionBuilder.outputsexplicitly