-
Notifications
You must be signed in to change notification settings - Fork 36
Usage Examples
LinFeng Qian edited this page Dec 19, 2019
·
4 revisions
# Generate a address with locktime
CKB> util to-multisig-addr --sighash-address ckt1qyqp5hera0n2ljm65ecvsakedw74jnl547sq77pnhz --locktime "2019-12-06T18:00:00+00:00"
address:
mainnet: ckb1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn323k5v49yzmvm0q0kfqw0hk0kyal6z32nwjvcqqr7qyzq8yqyxen2z
testnet: ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn323k5v49yzmvm0q0kfqw0hk0kyal6z32nwjvcqqr7qyzq8yqtec2wj
target_epoch: "Epoch { number: 51, index: 764, length: 1800 }"
# Transfer some capacity to above address (with locktime)
CKB> wallet transfer --from-account 0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1 --to-address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn323k5v49yzmvm0q0kfqw0hk0kyal6z32nwjvcqqr7qyzq8yqtec2wj --capacity 20000 --tx-fee 0.00001
Password:
0x6b9e2200b409a3435e70e34d8f96491c7a1d706afc84ba8f96f8616c5ca1847d
# Transfer from master private key
wallet transfer \
--from-account ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y \
--from-locked-address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudkscqqqqqqqgqyq0y7qxf \
--to-address ckt1qyqg7zchpds6lv3v0nr36z2msu2x9a5lkhrq7kvyww \
--capacity 19999.9999 \
--tx-fee 0.00001
# Password:
# 0xd3f1df20a4b87c01d77b0ab9877c9270c512ce3e9a4443deb0eb685112fc24e5
# Transfer from derived private key (bip32)
wallet transfer \
--from-account ckt1qyqd5eyygtdmwdr7ge736zw6z0ju6wsw7rssu8fcve \
--from-locked-address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn32s08dj83qavwc4l4ceyeta2ryhkahxrndxacqqqqqqqgqyqx3vx8k \
--to-address ckt1qyqvhx2mvdyujpzhpxxk7p5p7jkl0qynqg2qrgj5el \
--capacity 1999.9998 \
--tx-fee 0.0001 \
--derive-change-address ckt1qyq8r0rrv7hlsvhj7u0l90d6zxn87luzxjys95rgrn
# Password:
# 0xcfb9f660acb2c9c50aa29db04a9d2cc235b47ee94b2df18db5b206dbb6774669
# Build a multisig address with absolute epoch since
CKB> tx build-multisig-address --sighash-address ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y --since-absolute-epoch 61
lock-arg: 0x9e2578fd0679a24726b7930fffb99a721c26f8db3d00000000010020
lock-hash: 0x0486e7ec2a98b7a19a9f9fcabd8b58f046a36353677663330e512ec13576ea82
mainnet: ckb1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqlm8p7r
testnet: ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqsyxc6n
# Transfer 20000 capacity to the multisig address
CKB> wallet transfer --from-account 0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1 --to-address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqsyxc6n --capacity 20000 --tx-fee 0.0001
Password:
0x1aefd4b0b8e542bbc0f0e9e7f8109646feeb39a087f460aab108dd9e64b274f9
# Query the capacity of the multisig address
CKB> wallet get-capacity --address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqsyxc6n
total: 20000.0 (CKB)
# Initialize a complex transaction
CKB> tx init --tx-file ../tx.json
ok
cat ../tx.json
{
"transaction": {
"version": "0x0",
"cell_deps": [],
"header_deps": [],
"inputs": [],
"outputs": [],
"witnesses": [],
"outputs_data": []
},
"multisig_configs": {},
"signatures": {}
}
# Query the live cell of the multisig address
CKB> wallet get-live-cells --address ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqsyxc6n
current_capacity: 20000.0 (CKB)
current_count: 1
live_cells:
- capacity: 20000.0 (CKB)
data_bytes: 0
index:
output_index: 0
tx_index: 1
lock_hash: 0x0486e7ec2a98b7a19a9f9fcabd8b58f046a36353677663330e512ec13576ea82
mature: true
number: 56207
tx_hash: 0x1aefd4b0b8e542bbc0f0e9e7f8109646feeb39a087f460aab108dd9e64b274f9
tx_index: 0
type_hashes: ~
total_capacity: 20000.0 (CKB)
total_count: 1
# Add a multisig config of the mutlisig address
CKB> tx add-multisig-config --sighash-address ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y --tx-file ../tx.json
ok
# Add the live cell as input to the transaction
CKB> tx add-input --tx-hash 0x1aefd4b0b8e542bbc0f0e9e7f8109646feeb39a087f460aab108dd9e64b274f9 --index 0 --tx-file ../tx.json
ok
# Add a output to the transaction
CKB> tx add-output --to-sighash-address ckt1qyqg7zchpds6lv3v0nr36z2msu2x9a5lkhrq7kvyww --capacity 19999.9999 --tx-file ../tx.json
ok
# Show details of the transaction
CKB> tx info --tx-file ../tx.json
[input] ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn3238390r7sv7dzgunt0yc0l7ue5usuymudk0gqqqqqqqgqyqsyxc6n => 20000.0, (data-length: 0, type-script: none, lock-kind: multisig with since)
[output] ckt1qyqg7zchpds6lv3v0nr36z2msu2x9a5lkhrq7kvyww => 19999.9999, (data-length: 0, type-script: none, lock-kind: sighash(secp))
input_total: 20000.0 (CKB)
output_total: 19999.9999 (CKB)
tx_fee: 0.0001 (CKB)
# Sign input of this transaction and add it to tx.json, the from-account argument is the owner of the multisig address
CKB> tx sign-inputs --from-account 0xd4c85f3cb8a625d25febb5acdade5e5bf4824fda --add-signatures --tx-file ../tx.json
Password:
- lock-arg: 0x9e2578fd0679a24726b7930fffb99a721c26f8db3d00000000010020
signature: 0x0c44c12638277ffa6eafeac55cd918932f1cdbcfd4df413c11e8fb5b48f41ba22f738bad494e63d78c2bf2a4e0f4676db1d48d37f3d872d28bac70b2ef5a567a01
# Send this transaction
CKB> tx send --tx-file ../tx.json
0x9245ecb248ec88991a80dcb8fee3932fe694ddc4c7ee061fb38f2e27befacf47
# Query the target address
CKB> wallet get-capacity --address ckt1qyqg7zchpds6lv3v0nr36z2msu2x9a5lkhrq7kvyww
total: 19999.9999 (CKB)