nis-ruby 0.0.11.1 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/LICENSE +21 -0
- data/README.md +23 -43
- data/{samples/request_account.rb → examples/account.rb} +2 -10
- data/{samples/request_block.rb → examples/block.rb} +0 -0
- data/{samples/request_debug.rb → examples/debug.rb} +0 -8
- data/{samples/request_local.rb → examples/local.rb} +0 -5
- data/{samples/request_namespace.rb → examples/namespace.rb} +0 -3
- data/{samples/request_nis.rb → examples/nis.rb} +0 -0
- data/{samples/request_node.rb → examples/node.rb} +0 -9
- data/examples/shutdown.rb +6 -0
- data/examples/transactions/importance_transfer.rb +22 -0
- data/examples/transactions/mosaic_definition_creation.rb +50 -0
- data/examples/transactions/mosaic_supply_change.rb +24 -0
- data/examples/transactions/multisig.rb +26 -0
- data/examples/transactions/multisig_add_cosignatory.rb +31 -0
- data/examples/transactions/multisig_aggregate_modification.rb +28 -0
- data/examples/transactions/multisig_signature.rb +38 -0
- data/examples/transactions/provision_namespace.rb +19 -0
- data/examples/transactions/transfer.rb +22 -0
- data/lib/nis.rb +8 -4
- data/lib/nis/client.rb +2 -1
- data/lib/nis/endpoint/shutdown.rb +7 -0
- data/lib/nis/endpoint/transaction/announce.rb +1 -1
- data/lib/nis/endpoint/transaction/prepareAnnounce.rb +1 -1
- data/lib/nis/fee.rb +1 -0
- data/lib/nis/fee/importance_transfer.rb +22 -0
- data/lib/nis/fee/mosaic_definition_creation.rb +22 -0
- data/lib/nis/fee/mosaic_supply_change_transfer.rb +22 -0
- data/lib/nis/fee/multisig.rb +22 -0
- data/lib/nis/fee/multisig_aggregation_modification.rb +30 -0
- data/lib/nis/fee/provision_namespace.rb +32 -0
- data/lib/nis/fee/transfer.rb +51 -0
- data/lib/nis/keypair.rb +18 -0
- data/lib/nis/mixin/struct.rb +50 -0
- data/lib/nis/request.rb +1 -0
- data/lib/nis/request/announce.rb +10 -0
- data/lib/nis/request/prepare_announce.rb +48 -0
- data/lib/nis/struct/block.rb +1 -1
- data/lib/nis/struct/mosaic_properties.rb +2 -2
- data/lib/nis/transaction/importance_transfer.rb +25 -28
- data/lib/nis/transaction/mosaic_definition_creation.rb +33 -34
- data/lib/nis/transaction/mosaic_supply_change.rb +30 -30
- data/lib/nis/transaction/multisig.rb +17 -36
- data/lib/nis/transaction/multisig_aggregate_modification.rb +29 -31
- data/lib/nis/transaction/multisig_signature.rb +24 -23
- data/lib/nis/transaction/provision_namespace.rb +53 -33
- data/lib/nis/transaction/transfer.rb +22 -52
- data/lib/nis/util.rb +16 -13
- data/lib/nis/version.rb +1 -1
- data/nis.gemspec +2 -0
- metadata +62 -19
- data/lib/nis/mixin/network.rb +0 -20
- data/samples/request_importance_transfer_transaction.rb +0 -34
- data/samples/request_mosaic_definition_creation_transaction.rb +0 -62
- data/samples/request_mosaic_supply_change_transaction.rb +0 -35
- data/samples/request_multisig_add_cosignatory_transaction.rb +0 -58
- data/samples/request_multisig_aggregate_modification_transaction.rb +0 -45
- data/samples/request_multisig_signature_transaction.rb +0 -53
- data/samples/request_multisig_transaction.rb +0 -54
- data/samples/request_provision_namespace_transaction.rb +0 -31
- data/samples/request_transfer_transaction.rb +0 -47
data/lib/nis/mixin/network.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class Nis
|
2
|
-
module Mixin
|
3
|
-
module Network
|
4
|
-
# @return [Integer]
|
5
|
-
def version
|
6
|
-
(0x0000000F & @version)
|
7
|
-
end
|
8
|
-
|
9
|
-
# @return [Boolean]
|
10
|
-
def testnet?
|
11
|
-
(0xFFFFFFF0 & @version) == Nis::Util::TESTNET
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Boolean]
|
15
|
-
def mainnet?
|
16
|
-
(0xFFFFFFF0 & @version) == Nis::Util::MAINNET
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (Source)
|
5
|
-
A_ADDRESS = 'TAH4MBR6MNLZKJAVW5ZJCMFAL7RS5U2YODUQKLCT'.freeze
|
6
|
-
A_PRIVATE_KEY = '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'.freeze
|
7
|
-
A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a002258673519'.freeze
|
8
|
-
|
9
|
-
# Remote Account B (Dist)
|
10
|
-
B_PUBLIC_KEY = 'cc6c9485d15b992501e57fe3799487e99de272f79c5442de94eeb998b45e0144'.freeze
|
11
|
-
|
12
|
-
# build Transaction Object
|
13
|
-
tx = Nis::Transaction::ImportanceTransfer.new(
|
14
|
-
mode: Nis::Transaction::ImportanceTransfer::ACTIVATE,
|
15
|
-
remoteAccount: B_PUBLIC_KEY,
|
16
|
-
signer: A_PUBLIC_KEY,
|
17
|
-
timeStamp: Nis::Util.timestamp,
|
18
|
-
deadline: Nis::Util.timestamp + 43_200,
|
19
|
-
version: Nis::Util::TESTNET_VERSION_1
|
20
|
-
)
|
21
|
-
|
22
|
-
# build RequestPrepareAnnounce Object
|
23
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
24
|
-
transaction: tx,
|
25
|
-
privateKey: A_PRIVATE_KEY
|
26
|
-
)
|
27
|
-
|
28
|
-
# Create NIS instance
|
29
|
-
nis = Nis.new
|
30
|
-
|
31
|
-
# Send XEM request.
|
32
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
33
|
-
puts res.message
|
34
|
-
puts hr
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A
|
5
|
-
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
-
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
-
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
-
|
9
|
-
mosaic_id = Nis::Struct::MosaicId.new(
|
10
|
-
namespaceId: 'kon',
|
11
|
-
name: 'teas'
|
12
|
-
)
|
13
|
-
|
14
|
-
properties = Nis::Struct::MosaicProperties.new(
|
15
|
-
divisibility: 0,
|
16
|
-
initialSupply: 10_000,
|
17
|
-
supplyMutable: true,
|
18
|
-
transferable: true
|
19
|
-
)
|
20
|
-
|
21
|
-
levy = Nis::Struct::MosaicLevy.new(
|
22
|
-
type: 1,
|
23
|
-
recipient: A_ADDRESS,
|
24
|
-
mosaicId: {
|
25
|
-
namespaceId: 'nem',
|
26
|
-
name: 'xem'
|
27
|
-
},
|
28
|
-
fee: 1_000
|
29
|
-
)
|
30
|
-
|
31
|
-
definition = Nis::Struct::MosaicDefinition.new(
|
32
|
-
creator: A_PUBLIC_KEY,
|
33
|
-
id: mosaic_id,
|
34
|
-
description: 'Ho-kago Tea Time',
|
35
|
-
properties: properties,
|
36
|
-
levy: levy
|
37
|
-
)
|
38
|
-
|
39
|
-
# build Transaction Object
|
40
|
-
tx = Nis::Transaction::MosaicDefinitionCreation.new(
|
41
|
-
mosaicDefinition: definition,
|
42
|
-
creationFee: 500_000_000,
|
43
|
-
creationFeeSink: Nis::Util::MOSAIC_SINK[:testnet],
|
44
|
-
signer: A_PUBLIC_KEY,
|
45
|
-
timeStamp: Nis::Util.timestamp,
|
46
|
-
deadline: Nis::Util.timestamp + 43_200,
|
47
|
-
version: Nis::Util::TESTNET_VERSION_1
|
48
|
-
)
|
49
|
-
|
50
|
-
# build RequestPrepareAnnounce Object
|
51
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
52
|
-
transaction: tx,
|
53
|
-
privateKey: A_PRIVATE_KEY
|
54
|
-
)
|
55
|
-
|
56
|
-
# Create NIS instance
|
57
|
-
nis = Nis.new
|
58
|
-
|
59
|
-
# Send XEM request.
|
60
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
61
|
-
puts res.message
|
62
|
-
puts hr
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A
|
5
|
-
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
-
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
-
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
-
|
9
|
-
mosaic_id = Nis::Struct::MosaicId.new(
|
10
|
-
namespaceId: 'kon',
|
11
|
-
name: 'teas'
|
12
|
-
)
|
13
|
-
|
14
|
-
# build Transaction Object
|
15
|
-
tx = Nis::Transaction::MosaicSupplyChange.new(
|
16
|
-
mosaicId: mosaic_id,
|
17
|
-
supplyType: Nis::Transaction::MosaicSupplyChange::INCREASE,
|
18
|
-
delta: 1_000,
|
19
|
-
signer: A_PUBLIC_KEY,
|
20
|
-
timeStamp: Nis::Util.timestamp,
|
21
|
-
deadline: Nis::Util.timestamp + 43_200,
|
22
|
-
version: Nis::Util::TESTNET_VERSION_1
|
23
|
-
)
|
24
|
-
|
25
|
-
# build RequestPrepareAnnounce Object
|
26
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
27
|
-
transaction: tx,
|
28
|
-
privateKey: A_PRIVATE_KEY
|
29
|
-
)
|
30
|
-
|
31
|
-
nis = Nis.new
|
32
|
-
|
33
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
34
|
-
puts res.to_hash
|
35
|
-
puts hr
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (multisig)
|
5
|
-
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
-
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
-
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
-
|
9
|
-
# Account B (cosignatory)
|
10
|
-
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
-
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
-
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
-
|
14
|
-
# Account C (cosignatory)
|
15
|
-
C_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
16
|
-
C_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'.freeze
|
17
|
-
C_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'.freeze
|
18
|
-
|
19
|
-
mcm = Nis::Struct::MultisigCosignatoryModification.new(
|
20
|
-
modificationType: 1, # Add
|
21
|
-
cosignatoryAccount: C_PUBLIC_KEY
|
22
|
-
)
|
23
|
-
|
24
|
-
# build Transaction Object
|
25
|
-
tx = Nis::Transaction::MultisigAggregateModification.new(
|
26
|
-
modifications: [
|
27
|
-
mcm
|
28
|
-
],
|
29
|
-
minCosignatories: {
|
30
|
-
relativeChange: 2
|
31
|
-
},
|
32
|
-
signer: A_PUBLIC_KEY,
|
33
|
-
timeStamp: Nis::Util.timestamp,
|
34
|
-
deadline: Nis::Util.timestamp + 43_200,
|
35
|
-
version: Nis::Util::TESTNET_VERSION_1
|
36
|
-
)
|
37
|
-
|
38
|
-
mtx = Nis::Transaction::Multisig.new(
|
39
|
-
otherTrans: tx,
|
40
|
-
signer: B_PUBLIC_KEY,
|
41
|
-
timeStamp: Nis::Util.timestamp,
|
42
|
-
deadline: Nis::Util.timestamp + 43_200,
|
43
|
-
version: Nis::Util::TESTNET_VERSION_1
|
44
|
-
)
|
45
|
-
|
46
|
-
# build RequestPrepareAnnounce Object
|
47
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
48
|
-
transaction: mtx,
|
49
|
-
privateKey: B_PRIVATE_KEY
|
50
|
-
)
|
51
|
-
|
52
|
-
# Create NIS instance
|
53
|
-
nis = Nis.new
|
54
|
-
|
55
|
-
# Send XEM request.
|
56
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
57
|
-
puts res.message
|
58
|
-
puts hr
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (change to multisig)
|
5
|
-
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
-
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
-
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
-
|
9
|
-
# Account B (cosignatory)
|
10
|
-
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
-
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
-
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
-
|
14
|
-
mcm = Nis::Struct::MultisigCosignatoryModification.new(
|
15
|
-
modificationType: 1, # Add
|
16
|
-
cosignatoryAccount: B_PUBLIC_KEY
|
17
|
-
)
|
18
|
-
|
19
|
-
# build Transaction Object
|
20
|
-
tx = Nis::Transaction::MultisigAggregateModification.new(
|
21
|
-
modifications: [
|
22
|
-
mcm
|
23
|
-
],
|
24
|
-
minCosignatories: {
|
25
|
-
relativeChange: 1
|
26
|
-
},
|
27
|
-
signer: A_PUBLIC_KEY,
|
28
|
-
timeStamp: Nis::Util.timestamp,
|
29
|
-
deadline: Nis::Util.timestamp + 43_200,
|
30
|
-
version: Nis::Util::TESTNET_VERSION_1
|
31
|
-
)
|
32
|
-
|
33
|
-
# build RequestPrepareAnnounce Object
|
34
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
35
|
-
transaction: tx,
|
36
|
-
privateKey: A_PRIVATE_KEY
|
37
|
-
)
|
38
|
-
|
39
|
-
# Create NIS instance
|
40
|
-
nis = Nis.new
|
41
|
-
|
42
|
-
# Send XEM request.
|
43
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
44
|
-
puts res.message
|
45
|
-
puts hr
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (change to multisig)
|
5
|
-
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
-
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
-
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
-
|
9
|
-
# Account B (cosignatory)
|
10
|
-
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
-
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
-
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
-
|
14
|
-
# Account C (cosignatory)
|
15
|
-
C_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
16
|
-
C_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'.freeze
|
17
|
-
C_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'.freeze
|
18
|
-
|
19
|
-
nis = Nis.new
|
20
|
-
txes = nis.account_unconfirmed_transactions(address: C_ADDRESS)
|
21
|
-
|
22
|
-
unless txes.size > 0
|
23
|
-
puts 'There are no transactions to sign.'
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
|
27
|
-
hash = txes.first.meta.data
|
28
|
-
|
29
|
-
puts "Unconfirmed Transaction Hash: #{hash}"
|
30
|
-
puts hr
|
31
|
-
|
32
|
-
# build Transaction Object
|
33
|
-
tx = Nis::Transaction::MultisigSignature.new(
|
34
|
-
otherHash: { data: hash },
|
35
|
-
otherAccount: A_ADDRESS,
|
36
|
-
signer: C_PUBLIC_KEY,
|
37
|
-
timeStamp: Nis::Util.timestamp,
|
38
|
-
deadline: Nis::Util.timestamp + 43_200,
|
39
|
-
version: Nis::Util::TESTNET_VERSION_1
|
40
|
-
)
|
41
|
-
|
42
|
-
# build RequestPrepareAnnounce Object
|
43
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
44
|
-
transaction: tx,
|
45
|
-
privateKey: C_PRIVATE_KEY
|
46
|
-
)
|
47
|
-
|
48
|
-
# Create NIS instance
|
49
|
-
nis = Nis.new
|
50
|
-
|
51
|
-
# Send XEM request.
|
52
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
53
|
-
puts res.message
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (multisig)
|
5
|
-
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
-
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
-
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
-
|
9
|
-
# Account B (cosignatory)
|
10
|
-
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
-
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
-
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
-
|
14
|
-
# build Transaction Object
|
15
|
-
tx = Nis::Transaction::Transfer.new(
|
16
|
-
amount: 1_000_000,
|
17
|
-
recipient: B_ADDRESS,
|
18
|
-
message: Nis::Struct::Message.new('Hello'),
|
19
|
-
signer: A_PUBLIC_KEY,
|
20
|
-
timeStamp: Nis::Util.timestamp,
|
21
|
-
deadline: Nis::Util.timestamp + 43_200,
|
22
|
-
version: Nis::Util::TESTNET_VERSION_1
|
23
|
-
)
|
24
|
-
|
25
|
-
mtx = Nis::Transaction::Multisig.new(
|
26
|
-
otherTrans: tx,
|
27
|
-
signer: B_PUBLIC_KEY,
|
28
|
-
timeStamp: Nis::Util.timestamp,
|
29
|
-
deadline: Nis::Util.timestamp + 43_200,
|
30
|
-
version: Nis::Util::TESTNET_VERSION_1
|
31
|
-
)
|
32
|
-
|
33
|
-
# automatically calculate minimum fee if fee is not set.
|
34
|
-
puts 'Fee: %d' % tx.fee
|
35
|
-
|
36
|
-
# build RequestPrepareAnnounce Object
|
37
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
38
|
-
transaction: mtx,
|
39
|
-
privateKey: B_PRIVATE_KEY
|
40
|
-
)
|
41
|
-
|
42
|
-
# Create NIS instance
|
43
|
-
nis = Nis.new
|
44
|
-
|
45
|
-
# check banalces before sending XEM.
|
46
|
-
puts 'Account A => balance: %d' %
|
47
|
-
(nis.account_get address: A_ADDRESS)[:account][:balance]
|
48
|
-
puts 'Account B => balance: %d' %
|
49
|
-
(nis.account_get address: B_ADDRESS)[:account][:balance]
|
50
|
-
puts hr
|
51
|
-
|
52
|
-
# Send XEM request.
|
53
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
54
|
-
puts res.message
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A
|
5
|
-
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
-
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
-
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
-
|
9
|
-
# build Transaction Object
|
10
|
-
tx = Nis::Transaction::ProvisionNamespace.new(
|
11
|
-
newPart: 'kon',
|
12
|
-
parent: nil,
|
13
|
-
rentalFeeSink: Nis::Util::NAMESPACE_SINK[:testnet],
|
14
|
-
rentalFee: 5_000_000_000,
|
15
|
-
signer: A_PUBLIC_KEY,
|
16
|
-
timeStamp: Nis::Util.timestamp,
|
17
|
-
deadline: Nis::Util.timestamp + 43_200,
|
18
|
-
version: Nis::Util::TESTNET_VERSION_1
|
19
|
-
)
|
20
|
-
|
21
|
-
# build RequestPrepareAnnounce Object
|
22
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
23
|
-
transaction: tx,
|
24
|
-
privateKey: A_PRIVATE_KEY
|
25
|
-
)
|
26
|
-
|
27
|
-
nis = Nis.new
|
28
|
-
|
29
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
30
|
-
puts res.message
|
31
|
-
puts hr
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'nis'
|
2
|
-
hr = '-' * 64
|
3
|
-
|
4
|
-
# Account A (Source)
|
5
|
-
A_ADDRESS = 'TAH4MBR6MNLZKJAVW5ZJCMFAL7RS5U2YODUQKLCT'.freeze
|
6
|
-
A_PRIVATE_KEY = '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'.freeze
|
7
|
-
A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a002258673519'.freeze
|
8
|
-
|
9
|
-
# Account B (Dist)
|
10
|
-
B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
11
|
-
|
12
|
-
# build Transaction Object
|
13
|
-
tx = Nis::Transaction::Transfer.new(
|
14
|
-
amount: 1_000_000,
|
15
|
-
# fee: 3_000_000, # see below.
|
16
|
-
recipient: B_ADDRESS,
|
17
|
-
signer: A_PUBLIC_KEY,
|
18
|
-
message: Nis::Struct::Message.new('Hello'),
|
19
|
-
timeStamp: Nis::Util.timestamp,
|
20
|
-
deadline: Nis::Util.timestamp + 43_200,
|
21
|
-
version: Nis::Util::TESTNET_VERSION_1
|
22
|
-
)
|
23
|
-
|
24
|
-
# automatically calculate minimum fee if fee is not set.
|
25
|
-
puts 'Fee: %d' % tx.fee
|
26
|
-
|
27
|
-
# build RequestPrepareAnnounce Object
|
28
|
-
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
29
|
-
transaction: tx,
|
30
|
-
privateKey: A_PRIVATE_KEY
|
31
|
-
)
|
32
|
-
|
33
|
-
# Create NIS instance
|
34
|
-
nis = Nis.new
|
35
|
-
|
36
|
-
# check banalces before sending XEM.
|
37
|
-
puts 'Account A => balance: %d' %
|
38
|
-
(nis.account_get address: A_ADDRESS)[:account][:balance]
|
39
|
-
puts 'Account B => balance: %d' %
|
40
|
-
(nis.account_get address: B_ADDRESS)[:account][:balance]
|
41
|
-
puts hr
|
42
|
-
|
43
|
-
# Send XEM request.
|
44
|
-
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
45
|
-
puts res.message
|
46
|
-
|
47
|
-
# After several minutes, check Account A and B Balance.
|