feat(types): add TxInputHTLC and TxInputMultisig input types
Input types for HF1 HTLC and multisig transactions. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
30d174eaac
commit
1ca75f9e3f
2 changed files with 46 additions and 0 deletions
|
|
@ -202,6 +202,31 @@ type TxInputZC struct {
|
|||
// InputType returns the wire variant tag for ZC inputs.
|
||||
func (t TxInputZC) InputType() uint8 { return InputTypeZC }
|
||||
|
||||
// TxInputHTLC extends TxInputToKey with an HTLC origin hash (HF1+).
|
||||
// Wire order: HTLCOrigin (string) serialised BEFORE parent fields (C++ quirk).
|
||||
// Carries Amount, KeyOffsets, KeyImage, EtcDetails -- same as TxInputToKey.
|
||||
type TxInputHTLC struct {
|
||||
HTLCOrigin string // C++ field: hltc_origin (transposed in source)
|
||||
Amount uint64
|
||||
KeyOffsets []TxOutRef
|
||||
KeyImage KeyImage
|
||||
EtcDetails []byte // opaque variant vector
|
||||
}
|
||||
|
||||
// InputType returns the wire variant tag for HTLC inputs.
|
||||
func (t TxInputHTLC) InputType() uint8 { return InputTypeHTLC }
|
||||
|
||||
// TxInputMultisig spends from a multisig output (HF1+).
|
||||
type TxInputMultisig struct {
|
||||
Amount uint64
|
||||
MultisigOutID Hash // 32-byte hash identifying the multisig output
|
||||
SigsCount uint64
|
||||
EtcDetails []byte // opaque variant vector
|
||||
}
|
||||
|
||||
// InputType returns the wire variant tag for multisig inputs.
|
||||
func (t TxInputMultisig) InputType() uint8 { return InputTypeMultisig }
|
||||
|
||||
// TxOutputBare is a transparent (pre-Zarcanum) transaction output.
|
||||
type TxOutputBare struct {
|
||||
// Amount in atomic units.
|
||||
|
|
|
|||
|
|
@ -30,3 +30,24 @@ func TestTxOutHTLC_TargetType_Good(t *testing.T) {
|
|||
t.Errorf("TargetType: got %d, want %d", target.TargetType(), TargetTypeHTLC)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTxInputHTLC_InputType_Good(t *testing.T) {
|
||||
var input TxInput = TxInputHTLC{
|
||||
HTLCOrigin: "test",
|
||||
Amount: 1000,
|
||||
KeyImage: KeyImage{1},
|
||||
}
|
||||
if input.InputType() != InputTypeHTLC {
|
||||
t.Errorf("InputType: got %d, want %d", input.InputType(), InputTypeHTLC)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTxInputMultisig_InputType_Good(t *testing.T) {
|
||||
var input TxInput = TxInputMultisig{
|
||||
Amount: 500,
|
||||
SigsCount: 2,
|
||||
}
|
||||
if input.InputType() != InputTypeMultisig {
|
||||
t.Errorf("InputType: got %d, want %d", input.InputType(), InputTypeMultisig)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue