Skip to content

Commit

Permalink
feat: Adds support for Type Data2
Browse files Browse the repository at this point in the history
  • Loading branch information
Code Monad committed Sep 19, 2023
1 parent 5d229f6 commit f43aa55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type TransactionStatus string
const (
HashTypeData ScriptHashType = "data"
HashTypeData1 ScriptHashType = "data1"
HashTypeData2 ScriptHashType = "data2"
HashTypeType ScriptHashType = "type"

DepTypeCode DepType = "code"
Expand Down
2 changes: 2 additions & 0 deletions types/molecule.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ func (t ScriptHashType) Pack() *molecule.Byte {
b = 0x01
case HashTypeData1:
b = 0x02
case HashTypeData2:
b = 0x04
default:
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions types/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func SerializeHashTypeByte(hashType ScriptHashType) (byte, error) {
return 0x01, nil
case HashTypeData1:
return 0x02, nil
case HashTypeData2:
return 0x04, nil
default:
return 0, errors.New(string("unknown hash type " + hashType))
}
Expand All @@ -79,6 +81,8 @@ func DeserializeHashTypeByte(hashType byte) (ScriptHashType, error) {
return HashTypeType, nil
case 0x02:
return HashTypeData1, nil
case 0x04:
return HashTypeData2, nil
default:
return "", errors.New(fmt.Sprintf("invalid script hash_type: %x", hashType))
}
Expand Down

0 comments on commit f43aa55

Please sign in to comment.