Skip to content

Commit edae012

Browse files
committed
f - Add Java example for chain::Filter
1 parent c1f1283 commit edae012

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/blockdata.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ optional type that implements `chain::Filter`:
146146
```rust
147147
impl chain::Filter for Blockchain {
148148
fn register_tx(&self, txid: &Txid, script_pubkey: &Script) {
149-
//
149+
// <insert code for you to watch for this transaction on-chain>
150150
}
151151

152152
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) {
153-
//
153+
// <insert code for you to watch for this output on-chain>
154154
}
155155
}
156156
```
@@ -159,7 +159,17 @@ impl chain::Filter for Blockchain {
159159
<TabItem value="java">
160160

161161
```java
162-
// TODO
162+
Filter tx_filter = Filter.new_impl(new Filter.FilterInterface() {
163+
@Override
164+
public void register_tx(byte[] txid, byte[] script_pubkey) {
165+
// <insert code for you to watch for this transaction on-chain>
166+
}
167+
168+
@Override
169+
void register_output(OutPoint outpoint, byte[] script_pubkey) {
170+
// <insert code for you to watch for this output on-chain>
171+
}
172+
});
163173
```
164174

165175
</TabItem>

0 commit comments

Comments
 (0)