mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-201] Implemented the AddSubnetwork CLI tool. * [NOD-201] Fixed various bugs in AddSubnetwork. * [NOD-201] Fixed mempool maybeAcceptTransaction verifying gasLimit for a subnetwork registry transaction. * [NOD-201] Fixed serialization/deserialization bugs in addrIndex. * [NOD-201] Fixed BlockConfirmationsByHash not handling the zeroHash. * [NOD-201] Used btclog instead of go log. * [NOD-201] Made gasLimit a command-line flag. Made waitForSubnetworkToBecomeAccepted only return an error. * [NOD-201] Filtered out mempool transactions. * [NOD-201] Fixed embarrassing typos. * [NOD-201] Added subnetwork registry tx fee + appropriate cli flag. * [NOD-201] Skipped TXOs that can't pay for registration.
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/daglabs/btcd/blockdag"
|
|
"github.com/daglabs/btcd/btcec"
|
|
"github.com/daglabs/btcd/txscript"
|
|
"github.com/daglabs/btcd/wire"
|
|
)
|
|
|
|
func buildSubnetworkRegistryTx(cfg *config, fundingOutPoint *wire.OutPoint, fundingTx *wire.MsgTx, privateKey *btcec.PrivateKey) (*wire.MsgTx, error) {
|
|
txIn := &wire.TxIn{
|
|
PreviousOutPoint: *fundingOutPoint,
|
|
Sequence: wire.MaxTxInSequenceNum,
|
|
}
|
|
pkScript, err := txscript.PayToScriptHashScript(blockdag.OpTrueScript)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
txOut := &wire.TxOut{
|
|
PkScript: pkScript,
|
|
Value: fundingTx.TxOut[fundingOutPoint.Index].Value - cfg.RegistryTxFee,
|
|
}
|
|
registryTx := wire.NewRegistryMsgTx(1, []*wire.TxIn{txIn}, []*wire.TxOut{txOut}, cfg.GasLimit)
|
|
|
|
SignatureScript, err := txscript.SignatureScript(registryTx, 0, fundingTx.TxOut[fundingOutPoint.Index].PkScript,
|
|
txscript.SigHashAll, privateKey, true)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to build signature script: %s", err)
|
|
}
|
|
txIn.SignatureScript = SignatureScript
|
|
|
|
return registryTx, nil
|
|
}
|