-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathBuildTransferTransactionTest.java
37 lines (31 loc) · 1.52 KB
/
BuildTransferTransactionTest.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
package mercury;
import constant.ApiFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.nervos.ckb.sign.TransactionWithScriptGroups;
import org.nervos.mercury.model.TransferPayloadBuilder;
import org.nervos.mercury.model.common.AssetInfo;
import org.nervos.mercury.model.req.item.ItemFactory;
import org.nervos.mercury.model.req.payload.TransferPayload;
import java.io.IOException;
import java.math.BigInteger;
public class BuildTransferTransactionTest {
@Test
void testBuildTransferTransaction() throws IOException {
TransferPayloadBuilder builder = new TransferPayloadBuilder();
builder.assetInfo(AssetInfo.newCkbAsset());
builder.addFrom(ItemFactory.newAddressItem("ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqfqyerlanzmnkxtmd9ww9n7gr66k8jt4tclm9jnk"));
builder.addTo("ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqg958atl2zdh8jn3ch8lc72nt0cf864ecqdxm9zf",
BigInteger.valueOf(100));
builder.payFee(TransferPayload.PayFee.FROM);
builder.feeRate(1100L);
TransactionWithScriptGroups s =
ApiFactory.getApi().buildTransferTransaction(builder.build());
Assertions.assertNotNull(s.txView);
Assertions.assertNotNull(s.scriptGroups);
Assertions.assertNotNull(s.scriptGroups.get(0).getGroupType());
Assertions.assertNotNull(s.scriptGroups.get(0).getScript());
Assertions.assertNotNull(s.scriptGroups.get(0).getOutputIndices());
Assertions.assertNotNull(s.scriptGroups.get(0).getInputIndices());
}
}