-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTxrefEncodingExample.java
72 lines (54 loc) · 1.98 KB
/
TxrefEncodingExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package design.contract.example;
import design.contract.txref.Txref;
public class TxrefEncodingExample {
/**
* Create a txref for a mainnet transaction, with only a blockHeight and transactionIndex
*/
private static void createStandardMainnetTxref() {
int blockHeight = 170;
int transactionIndex = 1;
String txref = Txref.encode(blockHeight, transactionIndex);
System.out.println(txref);
// prints "tx1:r52q-qqpq-qpty-cfg"
}
/**
* Create a txref for a testnet transaction, with only a blockHeight and transactionIndex
*/
private static void createStandardTestnetTxref() {
int blockHeight = 170;
int transactionIndex = 1;
String txref = Txref.encodeTestnet(blockHeight, transactionIndex);
System.out.println(txref);
// prints "txtest1:x52q-qqpq-qvr9-ztk"
}
/**
* Create an extended txref for a mainnet transaction, with a blockHeight and
* transactionIndex and a specific txoIndex
*/
private static void createExtendedMainnetTxref() {
int blockHeight = 170;
int transactionIndex = 1;
int txoIndex = 1;
String txref = Txref.encode(blockHeight, transactionIndex, txoIndex);
System.out.println(txref);
// prints "tx1:y52q-qqpq-qpqq-4lkz-zc"
}
/**
* Create an extended txref for a testnet transaction, with a blockHeight and
* transactionIndex and a specific txoIndex
*/
private static void createExtendedTestnetTxref() {
int blockHeight = 170;
int transactionIndex = 1;
int txoIndex = 1;
String txref = Txref.encodeTestnet(blockHeight, transactionIndex, txoIndex);
System.out.println(txref);
// prints "txtest1:852q-qqpq-qpqq-m8ef-pl"
}
public static void main(String[] args) {
createStandardMainnetTxref();
createStandardTestnetTxref();
createExtendedMainnetTxref();
createExtendedTestnetTxref();
}
}