mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-09 13:34:44 +01:00
Co-authored-by: Marco Argentieri <tiero@users.noreply.github.com> * Add claim command * Persist pending data in sqlite repo * Remove debug log * Return pending data at interface level * Fix unlocking btc wallet after restart * Lint & Fix whitelist permissions * Fix send command for covenant * Update client/covenantless/claim.go Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> * Fix * Pay for min relay fee instead of estimating fees for redeem and unconf forfeit txs * Add support for pending payments (coventanless) * Fixes * Fixes * Improve verbosity * Fix coin selection * Fix --------- Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> Co-authored-by: louisinger <louis@vulpem.com> Co-authored-by: Marco Argentieri <tiero@users.noreply.github.com> Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package covenantless
|
|
|
|
import (
|
|
"github.com/ark-network/ark/common/bitcointree"
|
|
"github.com/btcsuite/btcd/txscript"
|
|
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
|
)
|
|
|
|
func computeVtxoTaprootScript(
|
|
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint,
|
|
) (*secp256k1.PublicKey, *txscript.TapscriptProof, error) {
|
|
redeemClosure := &bitcointree.CSVSigClosure{
|
|
Pubkey: userPubkey,
|
|
Seconds: exitDelay,
|
|
}
|
|
|
|
forfeitClosure := &bitcointree.MultisigClosure{
|
|
Pubkey: userPubkey,
|
|
AspPubkey: aspPubkey,
|
|
}
|
|
|
|
redeemLeaf, err := redeemClosure.Leaf()
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
forfeitLeaf, err := forfeitClosure.Leaf()
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
vtxoTaprootTree := txscript.AssembleTaprootScriptTree(
|
|
*redeemLeaf, *forfeitLeaf,
|
|
)
|
|
root := vtxoTaprootTree.RootNode.TapHash()
|
|
|
|
unspendableKey := bitcointree.UnspendableKey()
|
|
vtxoTaprootKey := txscript.ComputeTaprootOutputKey(unspendableKey, root[:])
|
|
|
|
redeemLeafHash := redeemLeaf.TapHash()
|
|
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
|
|
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
|
|
|
|
return vtxoTaprootKey, &proof, nil
|
|
}
|