mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
* [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>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package common
|
|
|
|
import (
|
|
"github.com/btcsuite/btcd/btcutil"
|
|
"github.com/btcsuite/btcd/txscript"
|
|
"github.com/btcsuite/btcwallet/waddrmgr"
|
|
"github.com/lightningnetwork/lnd/input"
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
|
)
|
|
|
|
var TreeTxSize = (&input.TxWeightEstimator{}).
|
|
AddTaprootKeySpendInput(txscript.SigHashDefault). // parent
|
|
AddP2TROutput(). // left child
|
|
AddP2TROutput(). // right child
|
|
VSize()
|
|
|
|
// liquid node size is 2x the bitcoin node size (avoid min-relay-fee issues with the low fee rate on liquid)
|
|
var CovenantTreeTxSize = TreeTxSize * 2
|
|
|
|
var ConnectorTxSize = (&input.TxWeightEstimator{}).
|
|
AddP2WKHInput().
|
|
AddP2WKHOutput().
|
|
AddP2WKHOutput().
|
|
VSize()
|
|
|
|
func ComputeForfeitMinRelayFee(feeRate chainfee.SatPerKVByte, vtxoScriptTapTree TaprootTree) (uint64, error) {
|
|
txWeightEstimator := &input.TxWeightEstimator{}
|
|
|
|
biggestVtxoLeafProof, err := BiggestLeafMerkleProof(vtxoScriptTapTree)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
ctrlBlock, err := txscript.ParseControlBlock(biggestVtxoLeafProof.ControlBlock)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
txWeightEstimator.AddP2PKHInput() // connector input
|
|
txWeightEstimator.AddTapscriptInput(
|
|
64*2, // forfeit witness = 2 signatures
|
|
&waddrmgr.Tapscript{
|
|
RevealedScript: biggestVtxoLeafProof.Script,
|
|
ControlBlock: ctrlBlock,
|
|
},
|
|
)
|
|
txWeightEstimator.AddP2TROutput() // asp output
|
|
|
|
return uint64(feeRate.FeeForVSize(lntypes.VByte(txWeightEstimator.VSize())).ToUnit(btcutil.AmountSatoshi)), nil
|
|
}
|