2

I have a bot for automated sending of XMR. The bot can send XMR to integrated addresses only, without separate payment ID support.

One customer has given me both a regular address and an old-style long payment ID. I have no feedback with this customer and I can't ask him to generate an integrated address or short payment ID.

I know an integrated address is made from a regular address and short payment ID, but the customer gave me a long payment ID. Is it possible to create an integrated address, which corresponds to a given pair? Otherwise, is it possible to convert the long payment ID to a short payment ID?

jtgrassie
  • 19,601
  • 4
  • 17
  • 54
ca6
  • 31
  • 1

1 Answers1

3

This really depends on how long the supplied payment ID is. Integrated addresses embed a short payment ID (64 bits - 8 bytes). So if the supplied payment ID is 8 bytes or less, yes, you can construct an integrated address using the supplied regular address and payment ID. Steps would be:

  1. Base58 decode the regular address
  2. Replace the first byte with byte 0x13
  3. Remove the last 4 bytes
  4. Append the payment ID (padded to 8 bytes if it's shorter)
  5. Append the first 4 bytes of the Keccak-256 hash of the above
  6. Base58 encode - this result is the integrated address.

You could alternatively just use the wallet RPC method make_integrated_address passing in the parameters standard_address and payment_id.

If the supplied payment ID is longer than 8 bytes, then no, you cannot create an integrated address using that payment ID and address.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54