Closed marekyggdrasil closed 3 years ago
(Using Python) Regarding point .3, After running init_send_tx, should I then also run receive_tx from the foreign API and the finalize_tx from the Owner API?
The wallets are created on the same device, in separate directories.
(So they use the same grin-wallet and node versions.)
* grin-wallet 5.0.0-beta.4
* grin node 5.0.0-rc.1
* Linux debian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
* wallet 1 address: grin1cwutd4sr0t0ac62764r9vz6wkgpmnmpheynh5tw56zvczvh8apdszxp25w
* wallet 2 address: grin1zygggqt5exf3zux7zaycgj8jv7gj005rhalewa3ap9kf3h74220q50mp8y
* Python version 3.7.3
* https://github.com/grinfans/grin.py/blob/main/wallet_v3.py
Run wallet (1) in Owner API listener mode in a separate window. This starts an HTTP Owner API server.
~$ grin-wallet owner_api
Password:
20201225 16:28:02.184 WARN grin_wallet_controller::controller - Starting HTTP Owner API server at 127.0.0.1:3420.
20201225 16:28:02.195 WARN grin_wallet_controller::controller - HTTP Owner listener started.
The HTTP Owner started succesfully.
Some configuration in the Python script must be done, before we can use it.
Main method of wallet_v3.py should be changed to look like the following listing. In particular, the variable args should be added like this:
if __name__ == '__main__':
import pprint
pp = pprint.PrettyPrinter(indent=4)
api_url = 'http://localhost:3420/v3/owner'
#change to your grin owner_api sercret file
api_sercet_file = '/home/nick-test/.grin/main/.owner_api_secret' # You have the change this
api_user = 'grin'
api_password = open(api_sercet_file).read().strip()
wallet = WalletV3(api_url, api_user, api_password)
wallet.init_secure_api()
#change to you wallet password
wallet_password = 'CHANGE-THIS'
wallet.open_wallet(None, wallet_password)
#pp.pprint(wallet.node_height())
#pp.pprint(wallet.retrieve_txs(tx_id="x"))
#pp.pprint(wallet.retrieve_txs())
pp.pprint(wallet.get_slatepack_address())
args = {
'src_acct_name': None,
'amount': 100000000,
'minimum_confirmations': 2,
'max_outputs': 500,
'num_change_outputs': 1,
'selection_strategy_is_use_all': False,
'target_slate_version': None,
'ttl_blocks': None,
'estimate_only': False,
'payment_proof_recipient_address': None,
'send_args': {
'dest': 'grin1zygggqt5exf3zux7zaycgj8jv7gj005rhalewa3ap9kf3h74220q50mp8y',
'post_tx': True,
'fluff': True,
'skip_tor': True,
}
}
result = wallet.init_send_tx(args)
pp.pprint(result)
# Create the slatepack that the recipient will need to when prompted during the receive command.
# Empty array for recipients
resp = wallet.create_slatepack_message(result, [])
pp.pprint(resp)
wallet.tx_lock_outputs(result)
Now, run this script from Wallet (1) (sender):
~$ python3 wallet_v3.py
'grin1cwutd4sr0t0ac62764r9vz6wkgpmnmpheynh5tw56zvczvh8apdszxp25w'
{ 'amt': '100000000',
'fee': '23000000',
'id': 'de80c2f0-0cc3-494f-8235-3f9bc2bcd98b',
'sigs': [ { 'nonce': '027247411a67e7e502e4f4b024746e0a54300ed2a96bb78ea6ef343b4ea1ce8e6a',
'xs': '028862292f8987d4868f36c943e803a1b7c02c86e7185cfef6b4558571a8a7e220'}],
'sta': 'S1',
'ver': '4:3'}
('BEGINSLATEPACK. 6zGhk3iGMxu9CK9 UPErRYLXC4ATGmj DqHUBirgQ2NvtAs '
'sWWcSe4QZ2q5Lne sV8tNM91KLLXQca octaCor6bsAuhbf sTLqp7MR6rDLdzh '
'swKz6rDqcd6rhE3 A2BK8MpqJ23uLS2 QXKhCURSttc4yCA dcioJTGUKncnuKc '
'KP36Bs2CvQcKhZL cYAA99WDEESeZdz S7XxWX4a3qc2q79 cRNDwJrnb. ENDSLATEPACK.')
The slatepack we need during the receive command is:
BEGINSLATEPACK. 6zGhk3iGMxu9CK9 UPErRYLXC4ATGmj DqHUBirgQ2NvtAs sWWcSe4QZ2q5Lne sV8tNM91KLLXQca octaCor6bsAuhbf sTLqp7MR6rDLdzh swKz6rDqcd6rhE3 A2BK8MpqJ23uLS2 QXKhCURSttc4yCA dcioJTGUKncnuKc KP36Bs2CvQcKhZL cYAA99WDEESeZdz S7XxWX4a3qc2q79 cRNDwJrnb. ENDSLATEPACK.
Grin wallet (2) before receive:
~/grin-wallet-2$ grin-wallet info
Password:
20201226 12:57:25.801 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201226 12:57:26.184 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 12:57:26.199 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 12:57:26.202 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 12:57:26.202 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete
____ Wallet Summary Info - Account 'default' as of height 1019008 ____
Confirmed Total | 0.476500000
Awaiting Confirmation (< 10) | 0.000000000
Awaiting Finalization | 0.000000000
Locked by previous transaction | 0.000000000
-------------------------------- | -------------
Currently Spendable | 0.476500000
Command 'info' completed successfully
Execute the receive command as done in #17:
~/grin-wallet-2$ grin-wallet receive --manual
Password:
Please paste your encoded slatepack message:
BEGINSLATEPACK. 6zGhk3iGMxu9CK9 UPErRYLXC4ATGmj DqHUBirgQ2NvtAs sWWcSe4QZ2q5Lne sV8tNM91KLLXQca octaCor6bsAuhbf sTLqp7MR6rDLdzh swKz6rDqcd6rhE3 A2BK8MpqJ23uLS2 QXKhCURSttc4yCA dcioJTGUKncnuKc KP36Bs2CvQcKhZL cYAA99WDEESeZdz S7XxWX4a3qc2q79 cRNDwJrnb. ENDSLATEPACK.
/home/nick-test/grin-wallet-2/slatepack/de80c2f0-0cc3-494f-8235-3f9bc2bcd98b.S2.slatepack
Slatepack data follows. Please provide this output to the other party
--- CUT BELOW THIS LINE ---
BEGINSLATEPACK. ArokUycwSJEBZPF U5YDSNxPVqn5cAE dPrD9o2PNu6Dix9 hr9nHHTsht9ymGq 9Z9NqmQKuVhSdJr fdEJrdRTnX8izMu D4kvQT3dz8B4Mr3 HPj5KkQ2hpMp18F J5pVuyzZVs12mFw QGbxxuWw7b7oRfB A3tGzehiukdSMP4 h99bEkWbsaSgtXr hFgSSQEgog8cPPs xUwzahcLFdrBiER YmjYnV6geeQF8KC HFvArxrHG9FNapg xgybYYHxLEj5Zur umgzzeTHTdfFMsg GQoaKHBZJidt7o5 Xcjo4zhvtF96T1z XvMSirKg3LdMik5 hSQy648CBtZ2LsZ d36c8XdenNmYzcm frW8aFXuLwggwdG HQ8FosdZGoaQjG6 31Mxon5QHbX7P8V DHdzCYyC38jng2H zMoXYrBsqqecEE1 cGVUvbzSqBdq3GA SW4a6LS1b4uk2nL RcUt8W7LdTi8Lq5 URpvYNRK5miDX9E JH1ZS2aALinin8t BM1Y1tofprZ6kjX hJ6hrP8mub1xqNV BFyXJYx48GXnxBS g57A74oxc8V5Xgp u5UX5df4yPennDb rJdrKhGUMeBvXvt 7McL5WzAaPPsmt1 WwedEgAHt4EjaFT AHw3KMRqzmAfdTW J6gP8K4XBfdg8xq UroPrWzKZ8SdJ7R xSScQrw7XRdCjBx ecHWrG6shawuPyT dA4WR5ozawpMpG4 JbM7ebw76ZvqxvR j1hjyivRGhqv92m F73egMn6JhrddQa bzUJDUu7vw7DoQN JYNKFEC4ekf57WK n2Us1HFtUYok4h9 1MoGCDdQL9wzL9E qmh5feWp2tug5az c61NjTRfQxMoqjE qvv1rd8jwEVgmAQ hwbmck87aw6avEa jC2hfXu4fYpxewu uHfCgNYVS35nriA QzSvmD19D7NC2ka E6uBw1X6y3sAbrN ossMc3KfD741rrH GLccPShYphgZAxJ Ssp2fppEkkwHFj3 BHygKsoxe6NZ8BV PQVtbWPKDMktJES 2uHj8AbX3HWTH2W RYkCJsN9DhMwt8m kWNxAJx6XipCTFj 7Lti7BLY34yqbAM XxHtgN1x18sWHci A53frVnRA7D9new Jz9NhS5LPWW1gd7 ASuQuqn4nqicPH1 AY7pjMxuEZxhxsw aAmaWWUxYHhekGA 1WvynsK9zG36dVT ND5AK7RtpfARnAh xKdZNN4iGtsT7TC XpzDeNsXTa3r5px mkAEszDph6n4BBn vZFxCYCdLJ71shn 4MAL2LnXnqHGysN mjv8ZNDUVpiJmnj WuqnhqaaeKHYdLe DEpV94cfrWwNvcF Naer3NfPkeoSmi9 sWQhXMz4brx9btd SHEt6Rb7mcsZLMB Z9Sdu. ENDSLATEPACK.
--- CUT ABOVE THIS LINE ---
Slatepack data was also output to
/home/nick-test/grin-wallet-2/slatepack/de80c2f0-0cc3-494f-8235-3f9bc2bcd98b.S2.slatepack
The slatepack data is NOT encrypted
Command 'receive' completed successfully
Wallet (2) state:
~/grin-wallet-2$ grin-wallet info
____ Wallet Summary Info - Account 'default' as of height 1019067 ____
Confirmed Total | 0.476500000
Awaiting Confirmation (< 10) | 0.000000000
Awaiting Finalization | 0.100000000
Locked by previous transaction | 0.000000000
-------------------------------- | -------------
Currently Spendable | 0.476500000
Command 'info' completed successfully
Wallet (1) state:
~$ grin-wallet info
____ Wallet Summary Info - Account 'default' as of height 1019066 ____
Confirmed Total | 0.000000000
Awaiting Confirmation (< 10) | 0.000000000
Awaiting Finalization | 4.338000000
Locked by previous transaction | 4.461000000
-------------------------------- | -------------
Currently Spendable | 0.000000000
Command 'info' completed successfully
Now, run the finalize command, as done in #17. Again, we need the slatepack we got during the receive command, from the recipient.
~$ grin-wallet finalize
Password:
Please paste your encoded slatepack message:
BEGINSLATEPACK. ArokUycwSJEBZPF U5YDSNxPVqn5cAE dPrD9o2PNu6Dix9 hr9nHHTsht9ymGq 9Z9NqmQKuVhSdJr fdEJrdRTnX8izMu D4kvQT3dz8B4Mr3 HPj5KkQ2hpMp18F J5pVuyzZVs12mFw QGbxxuWw7b7oRfB A3tGzehiukdSMP4 h99bEkWbsaSgtXr hFgSSQEgog8cPPs xUwzahcLFdrBiER YmjYnV6geeQF8KC HFvArxrHG9FNapg xgybYYHxLEj5Zur umgzzeTHTdfFMsg GQoaKHBZJidt7o5 Xcjo4zhvtF96T1z XvMSirKg3LdMik5 hSQy648CBtZ2LsZ d36c8XdenNmYzcm frW8aFXuLwggwdG HQ8FosdZGoaQjG6 31Mxon5QHbX7P8V DHdzCYyC38jng2H zMoXYrBsqqecEE1 cGVUvbzSqBdq3GA SW4a6LS1b4uk2nL RcUt8W7LdTi8Lq5 URpvYNRK5miDX9E JH1ZS2aALinin8t BM1Y1tofprZ6kjX hJ6hrP8mub1xqNV BFyXJYx48GXnxBS g57A74oxc8V5Xgp u5UX5df4yPennDb rJdrKhGUMeBvXvt 7McL5WzAaPPsmt1 WwedEgAHt4EjaFT AHw3KMRqzmAfdTW J6gP8K4XBfdg8xq UroPrWzKZ8SdJ7R xSScQrw7XRdCjBx ecHWrG6shawuPyT dA4WR5ozawpMpG4 JbM7ebw76ZvqxvR j1hjyivRGhqv92m F73egMn6JhrddQa bzUJDUu7vw7DoQN JYNKFEC4ekf57WK n2Us1HFtUYok4h9 1MoGCDdQL9wzL9E qmh5feWp2tug5az c61NjTRfQxMoqjE qvv1rd8jwEVgmAQ hwbmck87aw6avEa jC2hfXu4fYpxewu uHfCgNYVS35nriA QzSvmD19D7NC2ka E6uBw1X6y3sAbrN ossMc3KfD741rrH GLccPShYphgZAxJ Ssp2fppEkkwHFj3 BHygKsoxe6NZ8BV PQVtbWPKDMktJES 2uHj8AbX3HWTH2W RYkCJsN9DhMwt8m kWNxAJx6XipCTFj 7Lti7BLY34yqbAM XxHtgN1x18sWHci A53frVnRA7D9new Jz9NhS5LPWW1gd7 ASuQuqn4nqicPH1 AY7pjMxuEZxhxsw aAmaWWUxYHhekGA 1WvynsK9zG36dVT ND5AK7RtpfARnAh xKdZNN4iGtsT7TC XpzDeNsXTa3r5px mkAEszDph6n4BBn vZFxCYCdLJ71shn 4MAL2LnXnqHGysN mjv8ZNDUVpiJmnj WuqnhqaaeKHYdLe DEpV94cfrWwNvcF Naer3NfPkeoSmi9 sWQhXMz4brx9btd SHEt6Rb7mcsZLMB Z9Sdu. ENDSLATEPACK.
Transaction posted
Transaction finalized successfully
/home/nick-test/.grin/main/slatepack/de80c2f0-0cc3-494f-8235-3f9bc2bcd98b.S3.slatepack
Slatepack data follows.
--- CUT BELOW THIS LINE ---
BEGINSLATEPACK. HYJCVXEWK9j5ZQ4 P3hPRYnijxVGYxo wvL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9f EL5W4ZnoS8KmNaC iGz8MZeWtqsHHVm qwqegBwC1rbSg3F gSfZcjiS6CUiWNb yUbszszYnFQhQhJ goVrCwEs6BERUbt 5KxFGCyR9UXF5dA CvmARULh4Kqn8tU vAW7rQMpEAAgSC3 sr7eC9dBnsmVymk LQCSF6SumP3P3D4 1t7r6WLgjiXbue3 W6uCnhuoYRz7UDC XXEbDXXZPkspzcc P3K2VUXy241NqXW WuKfdJzbFRR4fAt pLGr1SfqMijfAin kTeL6cWWa5oTCFr ZKNHtyDugDwxnkR v7VC617fdeYSht8 9thMCECBsurXPCE GQSGsqh5zbrFzJt BqxDg1mxuZy1KUr yoD4nx5VNZhhKss ndnFPTHTLWqL92s kW4ezxtnVSwKAYd B5QW8YVb9eoQiw3 GwChtEovAK87Sza cqiBXHFkqidc9gh usfHntzUWdepR1w Nrb8NaiUKDoAxop Fru4YdYRBvdnS6u d66yougibQAT3QW DSBPyxoaCcxB1QT sCH19rfwuCnZGSj a9WyAE3TZyxq3tf QDEQn4K1Gd1ikgX 2BjJL2EAc3Keet3 zis1Agp7iNrEfAJ 24Pe18xMRPf5S3G cftRazyjEtx4nfd 19zjsrMBHLgPCcF rNDVPtumpWtU5vw 1PirBdXC8cB6nQe A1Xv81wVJx5T7q4 UKcfPPraBwVt26Z ZupvehntDxownqp 4dnoNTMbeBiiHRk dcHYMYusMreqCdh 1L1fmUbch3dSUC9 ubEkC3mRxSfM49L hN2oaFHtktRdr66 ApScjPdZTu1d8Fa Mft7CNQ77BaTRpE iSMovteFCWnuu9G chQNck6SzGVE5sR sAjiDsBY8iCQ19s z7Zek3jHgcXxBRk VUE6bwEFd4Nkm4Z bLSwWxvJYSnqZoe 9D4uJixxKHkJyAB fedFuvZcXZpnepz eDWZhjLAXrwstTZ p3TzcrkBYFMWoCh pFRcbQUgPYYWQC8 tCPAJnQcTCvsjrv Fk1H6BKAiKr9bLd e6xLhuRdQZVp4kH baRwwaLCZZQPdJ3 GoRxi2E1bW5Zdym c7w9eXtoEUyYWzB pgxiJ1WnxewYrsc VsmaLrLMLgAu7QC tRb2dV5UmG2qJz2 mJ6T12VGqEMsauT Bv4axLtsQYtNBqp qgEwzk23F3FMJ8z wLaHumEDy7sjCX3 bkMnVJRGKMR6umM 7VxGrwN7fzzQN5w 9LLHoGnUomxXvNz 4xHiAJMMuQcAAco BtBG6grohoTvdXt U9WGXgduec6iPjQ GVbSg9vLs4kADEU tEwhybNH3fUCeA9 koTqrUjeptZviKH Z381Y5yyYVpohsP 3HBYnPJX51U7WC8 YiMtmsJ6sAssUnZ gqEouU1hggLBiMV JYtg5kUX6Z8dYtb FrU1ske9XzjZNTW w32aRb6hc7EYxXT uzrFP1AFiith1zf 3J3Psn71xvB2bjS 6yebgxKKBRtWHTs 7sVmbvyjdvzprLJ kFyKVSo5nXwCm34 Ahaqzv9Y. ENDSLATEPACK.
--- CUT ABOVE THIS LINE ---
Slatepack data was also output to
/home/nick-test/.grin/main/slatepack/de80c2f0-0cc3-494f-8235-3f9bc2bcd98b.S3.slatepack
The slatepack data is NOT encrypted
Command 'finalize' completed successfully
Wallet (1) state, after the finalize command:
~$ grin-wallet info
Password:
20201226 14:01:58.985 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201226 14:01:59.010 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:01:59.024 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:01:59.024 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:01:59.025 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete
____ Wallet Summary Info - Account 'default' as of height 1019075 ____
Confirmed Total | 4.338000000
Awaiting Confirmation (< 10) | 4.338000000
Awaiting Finalization | 0.000000000
Locked by previous transaction | 0.000000000
-------------------------------- | -------------
Currently Spendable | 0.000000000
Command 'info' completed successfully
Wallet (2) state, after the finalize command. Compare this with previous command runs of grin-wallet info for Wallet (2). One can see that the confirmed total increased with 0.1 grin.
~/grin-wallet-2$ grin-wallet info
Password:
20201226 14:03:38.657 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201226 14:03:38.683 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:03:38.693 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:03:38.704 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:03:38.705 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201226 14:03:38.705 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete
____ Wallet Summary Info - Account 'default' as of height 1019075 ____
Confirmed Total | 0.576500000
Awaiting Confirmation (< 10) | 0.100000000
Awaiting Finalization | 0.000000000
Locked by previous transaction | 0.000000000
-------------------------------- | -------------
Currently Spendable | 0.476500000
Command 'info' completed successfully
The test case did run as expected.
Well done! And thanks for the gist report! Closing.
Description Testing the init send tx method from the Owner API
Prerequisites
Test procedure
send -> receive -> finalize
flow as done in https://github.com/Grinnode-live/2020-grin-bug-bash-challenge/issues/17Expected result: Expect the
send -> receive -> finalize
flow initiated by Owner API to work correctly as in https://github.com/Grinnode-live/2020-grin-bug-bash-challenge/issues/17Include the output of the following command for both wallets
and your environment