mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
* [domain] add reverse boarding inputs in Payment struct * [tx-builder] support reverse boarding script * [wallet] add GetTransaction * [api-spec][application] add reverse boarding support in covenantless * [config] add reverse boarding config * [api-spec] add ReverseBoardingAddress RPC * [domain][application] support empty forfeits txs in EndFinalization events * [tx-builder] optional connector output in round tx * [btc-embedded] fix getTx and taproot finalizer * whitelist ReverseBoardingAddress RPC * [test] add reverse boarding integration test * [client] support reverse boarding * [sdk] support reverse boarding * [e2e] add sleep time after faucet * [test] run using bitcoin-core RPC * [tx-builder] fix GetSweepInput * [application][tx-builder] support reverse onboarding in covenant * [cli] support reverse onboarding in covenant CLI * [test] rework integration tests * [sdk] remove onchain wallet, replace by onboarding address * remove old onboarding protocols * [sdk] Fix RegisterPayment * [e2e] add more funds to covenant ASP * [e2e] add sleeping time * several fixes * descriptor boarding * remove boarding delay from info * [sdk] implement descriptor boarding * go mod tidy * fixes and revert error msgs * move descriptor pkg to common * add replace in go.mod * [sdk] fix unit tests * rename DescriptorInput --> BoardingInput * genrest in SDK * remove boarding input from domain * remove all "reverse boarding" * rename "onboarding" ==> "boarding" * remove outdate payment unit test * use tmpfs docker volument for compose testing files * several fixes
46 lines
954 B
Go
46 lines
954 B
Go
package descriptor
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"errors"
|
|
|
|
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
|
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
|
)
|
|
|
|
const BoardingDescriptorTemplate = "tr(%s,{ and(pk(%s), pk(%s)), and(older(%d), pk(%s)) })"
|
|
|
|
func ParseBoardingDescriptor(
|
|
desc TaprootDescriptor,
|
|
) (user *secp256k1.PublicKey, timeout uint, err error) {
|
|
for _, leaf := range desc.ScriptTree {
|
|
if andLeaf, ok := leaf.(*And); ok {
|
|
if first, ok := andLeaf.First.(*Older); ok {
|
|
timeout = first.Timeout
|
|
}
|
|
|
|
if second, ok := andLeaf.Second.(*PK); ok {
|
|
keyBytes, err := hex.DecodeString(second.Key.Hex)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
|
|
user, err = schnorr.ParsePubKey(keyBytes)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if user == nil {
|
|
return nil, 0, errors.New("boarding descriptor is invalid")
|
|
}
|
|
|
|
if timeout == 0 {
|
|
return nil, 0, errors.New("boarding descriptor is invalid")
|
|
}
|
|
|
|
return
|
|
}
|