7

While reading about sweeping in the official documentation:

https://iota.readme.io/v1.2.0/docs/user-deposit-address-sweeping-to-internal-exchange-addresses#section-determine-the-correct-sweep-inputs

I see these initial variables:

const addresses = [
    'ZRMBFCFLJSEIHYSXGDMOJOCORBWSSGJDJMVZGWUYGXTJYUJQELKOXNWOYBYTMYEIHP9PPPKWDEVOYJPZH',
    'TXPETAIGWJGETC9Y9FKKLHIBZHO9KQESOHZBKEQBEAKJJKDQCSD9CRPKSZIXIGTPMLBVYXLHNNDMZFTSH'
]

// Address metadata
// hashes represent any unresolved sweeps
const metadata = [
    {security: 2, keyIndex: 1, user: 'Chris', hashes: []},
    {security: 3, keyIndex: 2, user: 'Dom', hashes: ['']}
]

But what are hashes actually? Do I obtain those from another API or do I compute it somehow? Why is one empty array while another one an array of empty string?

1 Answer 1

2

I assume that the empty array is a typo here, as the following code will always assume that hashes contains at least one element (either an empty string or a previous transaction hash). On the other hand it probably does not matter since both undefined and empty string are falsey in JavaScript.

The idea of the hashes variable is that you cache here the hash of the last transaction that swept that address. So when you sweep addresses and notice they have a balance, you can check the transaction hash whether it is alredy confirmed. If no, you should not sweep again (as the sweep is still pending), and if yes you should (after advising your user not to double spend to the same address) sweep the address again.

The hashes are filled in the snippet of the sending transfers section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.