mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-10 22:14:22 +01:00
* scaffolding wallet * remove wallet db, add loader instead * wip * implement some wallet methods * signing and utxos * renaming * fee estimator * chain source options * config * application service * clark docker-compose * CLI refactor * v0 clark * v0.1 clark * fix SignTapscriptInput (btcwallet) * wallet.Broadcast, send via explora * fix ASP pubkey * Use lnd's btcwallet & Add rpc to get wallet staus * wip * unilateral exit * Fixes on watching for notifications and cli init * handle non-final BIP68 errors * Fixes * Fixes * Fix * a * fix onboard cosigners + revert tree validation * fix covenant e2e tests * fix covenantless e2e tests * fix container naming * fix lint error * update REAME.md * Add env var for wallet password --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package covenant
|
|
|
|
import (
|
|
"github.com/ark-network/ark/common/tree"
|
|
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
|
"github.com/vulpemventures/go-elements/taproot"
|
|
)
|
|
|
|
func computeVtxoTaprootScript(
|
|
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint,
|
|
) (*secp256k1.PublicKey, *taproot.TapscriptElementsProof, error) {
|
|
redeemClosure := &tree.CSVSigClosure{
|
|
Pubkey: userPubkey,
|
|
Seconds: exitDelay,
|
|
}
|
|
|
|
forfeitClosure := &tree.ForfeitClosure{
|
|
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 := taproot.AssembleTaprootScriptTree(
|
|
*redeemLeaf, *forfeitLeaf,
|
|
)
|
|
root := vtxoTaprootTree.RootNode.TapHash()
|
|
|
|
unspendableKey := tree.UnspendableKey()
|
|
vtxoTaprootKey := taproot.ComputeTaprootOutputKey(unspendableKey, root[:])
|
|
|
|
redeemLeafHash := redeemLeaf.TapHash()
|
|
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
|
|
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
|
|
|
|
return vtxoTaprootKey, &proof, nil
|
|
}
|