mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 12:14:21 +01:00
Add reversible policy to pending vtxos (#311)
* [server] descriptor-based vtxo script * [server] fix unit tests * [sdk] descriptor based vtxo * empty config check & version flag support * fix: empty config check & version flag support (#309) * fix * [sdk] several fixes * [sdk][server] several fixes * [common][sdk] add reversible VtxoScript type, use it in async payment * [common] improve parser * [common] fix reversible vtxo parser * [sdk] remove logs * fix forfeit map * remove debug log * [sdk] do not allow reversible vtxo script in case of self-transfer * remove signing pubkey * remove signer public key, craft forfeit txs client side * go work sync * fix linter errors * rename MakeForfeitTxs to BuildForfeitTxs * fix conflicts * fix tests * comment VtxoScript type * revert ROUND_INTERVAL value --------- Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> Co-authored-by: sekulicd <sekula87@gmail.com>
This commit is contained in:
@@ -67,60 +67,34 @@ func CoinSelect(
|
||||
}
|
||||
|
||||
func ParseLiquidAddress(addr string) (
|
||||
bool, []byte, *secp256k1.PublicKey, error,
|
||||
bool, []byte, error,
|
||||
) {
|
||||
outputScript, err := address.ToOutputScript(addr)
|
||||
if err != nil {
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
}
|
||||
return false, nil, userPubkey, nil
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
return true, outputScript, nil, nil
|
||||
return true, outputScript, nil
|
||||
}
|
||||
|
||||
func ParseBitcoinAddress(addr string, net chaincfg.Params) (
|
||||
bool, []byte, *secp256k1.PublicKey, error,
|
||||
bool, []byte, error,
|
||||
) {
|
||||
btcAddr, err := btcutil.DecodeAddress(addr, &net)
|
||||
if err != nil {
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
}
|
||||
return false, nil, userPubkey, nil
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
onchainScript, err := txscript.PayToAddrScript(btcAddr)
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
return false, nil, err
|
||||
}
|
||||
return true, onchainScript, nil, nil
|
||||
return true, onchainScript, nil
|
||||
}
|
||||
|
||||
func IsBitcoinOnchainOnly(receivers []client.Output, net chaincfg.Params) bool {
|
||||
func IsOnchainOnly(receivers []client.Output) bool {
|
||||
for _, receiver := range receivers {
|
||||
isOnChain, _, _, err := ParseBitcoinAddress(receiver.Address, net)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !isOnChain {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func IsLiquidOnchainOnly(receivers []client.Output) bool {
|
||||
for _, receiver := range receivers {
|
||||
isOnChain, _, _, err := ParseLiquidAddress(receiver.Address)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
isOnChain := len(receiver.Address) > 0
|
||||
|
||||
if !isOnChain {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user