-
Notifications
You must be signed in to change notification settings - Fork 35
Add 0-value P2A output to offchain transactions #566
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
db58124
P2A in vtxo tree and redeem txs
louisinger 5e15e2f
update validation.go
louisinger 60fa78a
Merge remote-tracking branch origin/next-version into P2A
louisinger 5b1ad55
Merge remote-tracking branch 'origin/next-version' into P2A
louisinger eda6926
fix conflict
louisinger 6ed1cf3
fix linter error
louisinger 9a56ca8
fix test unilateral exit
louisinger 0c3ee47
fix bitcoin_wallet.go
louisinger 1491565
e2e test: faucet onchain
louisinger c45eb40
fixes
louisinger bef44d9
NewAddresses returns onchain P2TR addresses
louisinger a9bc644
e2e tests: add TODOs
louisinger b40cb0e
fixes after reviews
louisinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package tree | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/btcsuite/btcd/btcutil/psbt" | ||
"github.com/btcsuite/btcd/txscript" | ||
"github.com/btcsuite/btcd/wire" | ||
) | ||
|
||
var ( | ||
ANCHOR_PKSCRIPT = []byte{ | ||
0x51, 0x02, 0x4e, 0x73, | ||
} | ||
ANCHOR_VALUE = int64(0) | ||
) | ||
|
||
func AnchorOutput() *wire.TxOut { | ||
return &wire.TxOut{ | ||
Value: ANCHOR_VALUE, | ||
PkScript: ANCHOR_PKSCRIPT, | ||
} | ||
} | ||
|
||
// ExtractWithAnchors extracts the final witness and scriptSig from psbt fields and ignores anchor inputs without failing. | ||
func ExtractWithAnchors(p *psbt.Packet) (*wire.MsgTx, error) { | ||
finalTx := p.UnsignedTx.Copy() | ||
|
||
for i, tin := range finalTx.TxIn { | ||
pInput := p.Inputs[i] | ||
|
||
// ignore anchor outputs | ||
if pInput.WitnessUtxo != nil && bytes.Equal(pInput.WitnessUtxo.PkScript, ANCHOR_PKSCRIPT) { | ||
continue | ||
} | ||
|
||
if pInput.FinalScriptSig != nil { | ||
tin.SignatureScript = pInput.FinalScriptSig | ||
} | ||
|
||
if pInput.FinalScriptWitness != nil { | ||
witnessReader := bytes.NewReader( | ||
pInput.FinalScriptWitness, | ||
) | ||
|
||
witCount, err := wire.ReadVarInt(witnessReader, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tin.Witness = make(wire.TxWitness, witCount) | ||
for j := uint64(0); j < witCount; j++ { | ||
wit, err := wire.ReadVarBytes( | ||
witnessReader, 0, | ||
txscript.MaxScriptSize, "witness", | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
tin.Witness[j] = wit | ||
} | ||
} | ||
} | ||
|
||
return finalTx, nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.