Skip to content

feat(rs-sdk): withdraw_address_funds should accept Address, not just CoreScript #3086

@thephez

Description

@thephez

Problem

There is an API asymmetry between the two withdrawal methods in rs-sdk:

  • WithdrawFromIdentity::withdraw() accepts Option<Address> and converts internally to CoreScript via CoreScript::new(address.script_pubkey()) (withdraw_from_identity.rs)

  • WithdrawAddressFunds::withdraw_address_funds() requires CoreScript directly — there is no Address convenience (address_credit_withdrawal.rs)

This asymmetry propagates to the WASM SDK / evo-sdk layer:

  • identities.creditWithdrawal() accepts a toAddress: string
  • addresses.withdraw() requires an outputScript: CoreScript object, forcing users to manually construct a CoreScript via CoreScript.newP2PKH(keyHashBytes) or CoreScript.newP2SH(scriptHashBytes)

Proposed Solution

Add an Address-accepting convenience to WithdrawAddressFunds (either a second trait method or modify the existing signature to accept Address and convert internally, matching the pattern in WithdrawFromIdentity).

Then update the WASM SDK's AddressFundsWithdrawOptions to accept an optional toAddress: string (like IdentityCreditWithdrawalOptions already does), parsing it with Address::from_str().

Relevant Files

  • packages/rs-sdk/src/platform/transition/address_credit_withdrawal.rsWithdrawAddressFunds trait (accepts CoreScript)
  • packages/rs-sdk/src/platform/transition/withdraw_from_identity.rsWithdrawFromIdentity trait (accepts Address, converts to CoreScript at line 50)
  • packages/wasm-sdk/src/state_transitions/addresses.rs — WASM AddressFundsWithdrawOptions (requires CoreScript)
  • packages/wasm-sdk/src/state_transitions/identity.rs — WASM IdentityCreditWithdrawalOptions (accepts toAddress: string)
  • packages/wasm-dpp2/src/core_script.rsCoreScriptWasm (has toAddress() but no fromAddress())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions