File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -203,3 +203,11 @@ Only output transactions with outputs matching a particular address
203
203
` ` ` bash
204
204
$ snek -filter-type chainsync.transaction -filter-address addr1qyht4ja0zcn45qvyx477qlyp6j5ftu5ng0prt9608dxp6l2j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pq4jxtdy
205
205
` ` `
206
+
207
+ # ### Filtering on a stake address
208
+
209
+ Only output transactions with outputs matching a particular stake address
210
+
211
+ ` ` ` bash
212
+ $ snek -filter-type chainsync.transaction -filter-address stake1u9f9v0z5zzlldgx58n8tklphu8mf7h4jvp2j2gddluemnssjfnkzz
213
+ ` ` `
Original file line number Diff line number Diff line change 15
15
package chainsync
16
16
17
17
import (
18
+ "strings"
19
+
18
20
"github.com/blinklabs-io/gouroboros/ledger"
19
21
"github.com/blinklabs-io/snek/event"
20
22
"github.com/blinklabs-io/snek/input/chainsync"
@@ -56,14 +58,26 @@ func (c *ChainSync) Start() error {
56
58
case chainsync.TransactionEvent :
57
59
// Check address filter
58
60
if c .filterAddress != "" {
61
+ isStakeAddress := false
62
+ if strings .HasPrefix (c .filterAddress , "stake" ) {
63
+ isStakeAddress = true
64
+ }
59
65
foundMatch := false
60
- // TODO: extract and compare stake addresses when this is done
61
- // https://github.com/blinklabs-io/gouroboros/issues/302
62
66
for _ , output := range v .Outputs {
63
67
if output .Address ().String () == c .filterAddress {
64
68
foundMatch = true
65
69
break
66
70
}
71
+ if isStakeAddress {
72
+ stakeAddr := output .Address ().StakeAddress ()
73
+ if stakeAddr == nil {
74
+ continue
75
+ }
76
+ if stakeAddr .String () == c .filterAddress {
77
+ foundMatch = true
78
+ break
79
+ }
80
+ }
67
81
}
68
82
if ! foundMatch {
69
83
continue
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module github.com/blinklabs-io/snek
3
3
go 1.18
4
4
5
5
require (
6
- github.com/blinklabs-io/gouroboros v0.44.0
6
+ github.com/blinklabs-io/gouroboros v0.45.1
7
7
github.com/kelseyhightower/envconfig v1.4.0
8
8
go.uber.org/zap v1.24.0
9
9
gopkg.in/yaml.v2 v2.4.0
Original file line number Diff line number Diff line change 1
1
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8 =
2
- github.com/blinklabs-io/gouroboros v0.44.0 h1:bvhMAqU9ZUh1WYrx8lMUj87h4QeFCXLZJaZ4bLlfxlE =
3
- github.com/blinklabs-io/gouroboros v0.44.0 /go.mod h1:YNHQqwU1yv620T5C+umkDmYf8BgBHlm6QpI9LUQ3Jhw =
2
+ github.com/blinklabs-io/gouroboros v0.45.1 h1:DhlQMeiBphuEMWn3grVAZsWO5OcM62UHsEe69+qCEnM =
3
+ github.com/blinklabs-io/gouroboros v0.45.1 /go.mod h1:YNHQqwU1yv620T5C+umkDmYf8BgBHlm6QpI9LUQ3Jhw =
4
4
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
5
5
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
6
6
github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
You can’t perform that action at this time.
0 commit comments