Skip to content

Commit

Permalink
Merge pull request #51 from BitcoinSchema/update/ord
Browse files Browse the repository at this point in the history
add vout to ord object
  • Loading branch information
rohenaz authored Mar 18, 2023
2 parents 46d3554 + cbe3036 commit 6c31651
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bitcoinschema/go-bitcoin/v2 v2.0.3
github.com/bitcoinschema/go-bob v0.3.3
github.com/bitcoinschema/go-boost v0.0.1
github.com/bitcoinschema/go-bpu v0.0.4
github.com/bitcoinschema/go-bpu v0.0.5
github.com/bitcoinschema/go-map v0.0.16
github.com/libsv/go-bt/v2 v2.1.1
)
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ github.com/bitcoinschema/go-bob v0.3.3/go.mod h1:u381SnwMDRJqbUIZxredI9sdl6J4WYM
github.com/bitcoinschema/go-boost v0.0.1 h1:yDBIUEjDc51HPPdag4WgAnHvFFEZUsBOGfOGdBlrGkc=
github.com/bitcoinschema/go-boost v0.0.1/go.mod h1:Z+15n8CgM1VV1Cx8CQOAo/RFUn0lXqk5OzrmtI2gyI0=
github.com/bitcoinschema/go-bpu v0.0.3/go.mod h1:i41D9NP5KIk/oCt8XrRhN27YerZCUG6vjScXDhNn5Us=
github.com/bitcoinschema/go-bpu v0.0.4 h1:EapuVhZcRD8ZOqBCcHUdzaMGOUmabvuXc6EvONBn5Mc=
github.com/bitcoinschema/go-bpu v0.0.4/go.mod h1:i41D9NP5KIk/oCt8XrRhN27YerZCUG6vjScXDhNn5Us=
github.com/bitcoinschema/go-bpu v0.0.5 h1:+RZa6WL/K0F7s1cKcBV5WumZcGG2uQ+SlhZjoSu403A=
github.com/bitcoinschema/go-bpu v0.0.5/go.mod h1:i41D9NP5KIk/oCt8XrRhN27YerZCUG6vjScXDhNn5Us=
github.com/bitcoinschema/go-map v0.0.16 h1:sc94gO52+M5Gb/f4RWxexqTa1riRg6ST3NzYUMynXTs=
github.com/bitcoinschema/go-map v0.0.16/go.mod h1:UATfKAVX5ILxhzCg0xOg9liqzGcY5Sz6XrH+V+CIbpY=
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 h1:2yTIV9u7H0BhRDGXH5xrAwAz7XibWJtX2dNezMeNsUo=
Expand Down
15 changes: 2 additions & 13 deletions ord/ord.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Prefix string = "ord"
type Ordinal struct {
Data []byte
ContentType string
Vout uint8
}

// FromTape sets the ordinal data from a bpu.Tape
Expand All @@ -26,7 +27,7 @@ func (o *Ordinal) FromTape(tape *bpu.Tape) (err error) {
if len(ordScript) == minOrdScriptPushes {
prefix := ordScript[2].S
if prefix != nil && *prefix == "ord" {

o.Vout = tape.I
for idx, push := range ordScript {
if push.Op != nil && *push.Op == bscript.Op1 {
if ordScript[idx+1].S != nil {
Expand All @@ -45,18 +46,6 @@ func (o *Ordinal) FromTape(tape *bpu.Tape) (err error) {
}
}
}

// data := tape.Cell[9].B
// contentType := tape.Cell[11].S
// if data != nil && contentType != nil {
// var dataBytes []byte
// dataBytes, err = base64.StdEncoding.DecodeString(*data)
// if err != nil {
// return
// }
// o.Data = dataBytes
// o.ContentType = *contentType
// }
return
}

Expand Down
246 changes: 246 additions & 0 deletions test/bob/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
{
"tx": {
"h": "ce7429a101b7aecdf1e5449151d0be17a3948cb5c22282832ae942107edb2272"
},
"in": [
{
"i": 0,
"tape": [
{
"cell": [
{
"b": "MEQCIDUGRtDdmf2I2p1vcA2s4fMuBcmnSi5kOI2chSiFrYQKAiAq8XSIx8EbM2oKJJC9t/SFXTGnJBfE7mRKdGOVR7zIB0E=",
"s": "0D\u0002 5\u0006F�ݙ��ڝop\r���.\u0005ɧJ.d8���(���\n\u0002 *�t���\u001b3j\n$����]1�$\u0017��dJtc�G��\u0007A",
"ii": 0,
"i": 0
},
{
"b": "A/20DJgUWAXROgZTKDRmcC0ja306xpg3SiMTPy3QKhqQ",
"s": "\u0003��\f\u0014X\u0005�:\u0006S(4fp-#k}:Ƙ7J#\u0013?-�*\u001a",
"ii": 1,
"i": 1
}
],
"i": 0
}
],
"e": {
"h": "f8448e73fc7667b91f86cf152b9bc4d88c365174989d79871e64ca8c66c1e785",
"i": 0,
"a": "1P1dKk7BCB6iTUz13w1eXkLfcj8a8dC4iv"
},
"seq": 4294967295
}
],
"out": [
{
"i": 0,
"tape": [
{
"cell": [
{
"op": 0,
"ops": "OP_0",
"ii": 0,
"i": 0
},
{
"op": 106,
"ops": "OP_RETURN",
"ii": 1,
"i": 1
}
],
"i": 0
},
{
"cell": [
{
"b": "MVB1UWE3SzYyTWlLQ3Rzc1NMS3kxa2g1NldXVTdNdFVSNQ==",
"s": "1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5",
"ii": 2,
"i": 0
},
{
"b": "U0VU",
"s": "SET",
"ii": 3,
"i": 1
},
{
"b": "YXBw",
"s": "app",
"ii": 4,
"i": 2
},
{
"b": "MnBheW1haWw=",
"s": "2paymail",
"ii": 5,
"i": 3
},
{
"b": "cGF5bWFpbA==",
"s": "paymail",
"ii": 6,
"i": 4
},
{
"b": "aGFnYmFyZEBtb25leWJ1dHRvbi5jb20=",
"s": "[email protected]",
"ii": 7,
"i": 5
},
{
"b": "cHVibGljX2tleQ==",
"s": "public_key",
"ii": 8,
"i": 6
},
{
"b": "MDJjODliNjc5MGViNjA1MDYyYTMxZjEyNDI1MDU5NGJkMGZkMDI5ODhkYTI1NDFiM2QyNWU3ZWYzOTM3ZmI0YWUw",
"s": "02c89b6790eb605062a31f124250594bd0fd02988da2541b3d25e7ef3937fb4ae0",
"ii": 9,
"i": 7
},
{
"b": "cGxhdGZvcm0=",
"s": "platform",
"ii": 10,
"i": 8
},
{
"b": "dHdpdHRlcg==",
"s": "twitter",
"ii": 11,
"i": 9
},
{
"b": "cHJvb2ZfdXJs",
"s": "proof_url",
"ii": 12,
"i": 10
},
{
"b": "aHR0cHM6Ly90d2l0dGVyLmNvbS9oYWdiYXJkZGQvc3RhdHVzLzEyMDUxODk1ODAzMDkzNzcwMjQ=",
"s": "https://twitter.com/hagbarddd/status/1205189580309377024",
"ii": 13,
"i": 11
},
{
"b": "cHJvb2ZfYm9keQ==",
"s": "proof_body",
"ii": 14,
"i": 12
},
{
"b": "SGkKCk15IHBheW1haWwgaXMgaGFnYmFyZEBtb25leWJ1dHRvbi5jb20=",
"s": "Hi\n\nMy paymail is [email protected]",
"ii": 15,
"i": 13
},
{
"b": "cHJvb2ZfaWQ=",
"s": "proof_id",
"ii": 16,
"i": 14
},
{
"b": "Sms5dlFncGREcG9XMHFEWQ==",
"s": "Jk9vQgpdDpoW0qDY",
"ii": 17,
"i": 15
}
],
"i": 1
},
{
"cell": [
{
"b": "MXNpZ255Q2l6cDFWeUJzSjVTczJ0RUFndzd6Q1lOSnU0",
"s": "1signyCizp1VyBsJ5Ss2tEAgw7zCYNJu4",
"ii": 19,
"i": 0
},
{
"b": "SU5LRmIxNU1uQVhxTlFueStiNEtBVm5HTnR5bUcwZEhTdTEzKzg3MSt0aTBXTjVGQmVBLzdEZ1VuMXRsdzZGN29kYlc3SURyVmVQS1RMclRQQWlEcXlvPQ==",
"s": "INKFb15MnAXqNQny+b4KAVnGNtymG0dHSu13+871+ti0WN5FBeA/7DgUn1tlw6F7odbW7IDrVePKTLrTPAiDqyo=",
"ii": 20,
"i": 1
},
{
"b": "MDJjODliNjc5MGViNjA1MDYyYTMxZjEyNDI1MDU5NGJkMGZkMDI5ODhkYTI1NDFiM2QyNWU3ZWYzOTM3ZmI0YWUw",
"s": "02c89b6790eb605062a31f124250594bd0fd02988da2541b3d25e7ef3937fb4ae0",
"ii": 21,
"i": 2
},
{
"b": "aGFnYmFyZEBtb25leWJ1dHRvbi5jb20=",
"s": "[email protected]",
"ii": 22,
"i": 3
}
],
"i": 2
}
],
"e": {
"v": 0,
"i": 0,
"a": "false"
}
},
{
"i": 1,
"tape": [
{
"cell": [
{
"op": 118,
"ops": "OP_DUP",
"ii": 0,
"i": 0
},
{
"op": 169,
"ops": "OP_HASH160",
"ii": 1,
"i": 1
},
{
"b": "7njcAgMt9eekcx5JZXFDoaThy9M=",
"s": "�x�\u0002\u0003-��s\u001eIeqC�����",
"ii": 2,
"i": 2
},
{
"op": 136,
"ops": "OP_EQUALVERIFY",
"ii": 3,
"i": 3
},
{
"op": 172,
"ops": "OP_CHECKSIG",
"ii": 4,
"i": 4
}
],
"i": 0
}
],
"e": {
"v": 31202,
"i": 1,
"a": "1Njvc7dj8UHG6hnV5k5ZjSJtPgTofknDmx"
}
}
],
"lock": 0,
"blk": {
"i": 618112,
"h": "000000000000000001e1e1f2995c9ba2e316f6fb85c247c923c591e56ea00fb6",
"t": 1579328162
},
"i": 478
}
Loading

0 comments on commit 6c31651

Please sign in to comment.