File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,28 @@ func (t *ConwayTransactionWitnessSet) UnmarshalCBOR(cborData []byte) error {
199199 return t .UnmarshalCbor (cborData , t )
200200}
201201
202+ type ConwayTransactionInput struct {
203+ shelley.ShelleyTransactionInput
204+ }
205+
206+ func NewConwayTransactionInput (hash string , idx int ) ConwayTransactionInput {
207+ tmpHash , err := hex .DecodeString (hash )
208+ if err != nil {
209+ panic (fmt .Sprintf ("failed to decode transaction hash: %s" , err ))
210+ }
211+ return ConwayTransactionInput {
212+ ShelleyTransactionInput : shelley.ShelleyTransactionInput {
213+ TxId : common .Blake2b256 (tmpHash ),
214+ OutputIndex : uint32 (idx ),
215+ },
216+ }
217+ }
218+
219+ func (i * ConwayTransactionInput ) UnmarshalCBOR (data []byte ) error {
220+ // We override the unmarshal function from ShelleyTransactionInput
221+ return cbor .DecodeGeneric (data , & i .ShelleyTransactionInput )
222+ }
223+
202224type ConwayTransactionBody struct {
203225 babbage.BabbageTransactionBody
204226 TxVotingProcedures common.VotingProcedures `cbor:"19,keyasint,omitempty"`
Original file line number Diff line number Diff line change @@ -386,15 +386,23 @@ func (i ShelleyTransactionInput) Utxorpc() *utxorpc.TxInput {
386386 return & utxorpc.TxInput {
387387 TxHash : i .TxId .Bytes (),
388388 OutputIndex : i .OutputIndex ,
389- // AsOutput: i.AsOutput,
390- // Redeemer: i.Redeemer,
391389 }
392390}
393391
394392func (i ShelleyTransactionInput ) String () string {
395393 return fmt .Sprintf ("%s#%d" , i .TxId , i .OutputIndex )
396394}
397395
396+ func (i * ShelleyTransactionInput ) UnmarshalCBOR (data []byte ) error {
397+ // Make sure this isn't a tag-wrapped set
398+ // This is needed to prevent Conway+ TXs from being decoded as an earlier type
399+ var tmpTag cbor.RawTag
400+ if _ , err := cbor .Decode (data , & tmpTag ); err == nil {
401+ return fmt .Errorf ("did not expect CBOR tag" )
402+ }
403+ return cbor .DecodeGeneric (data , i )
404+ }
405+
398406func (i ShelleyTransactionInput ) MarshalJSON () ([]byte , error ) {
399407 return []byte ("\" " + i .String () + "\" " ), nil
400408}
You can’t perform that action at this time.
0 commit comments