
Product
Introducing Custom Pull Request Alert Comment Headers
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
@onekeyfe/cardano-coin-selection
Advanced tools
Minimal implementation of Cardano coin selection algorithms (see CIP-2) developed solely for OneKeyHQ. Under the hood it leverages Cardano Serialization Lib via WASM module.
const txPlan = coinSelection(
txParams: {
utxos: Utxo[];
outputs: UserOutput[];
changeAddress: string;
certificates: Certificate[];
withdrawals: Withdrawal[];
accountPubKey: string;
ttl?: number;
},
options: {
feeParams?: { a: string };
debug?: boolean;
forceLargestFirstSelection?: boolean;
}
);
coinSelection(txParams, options)
txParams
utxos
: Array of account's utxooutputs
: Requested outputs provided by an userchangeAddress
: An address where the change will be sentcertificates
: Stake registration and/or delegation certificates (stake pool registration is not supported)withdrawals
: Withdrawal requestsaccountPubKey
: Account public keyttl
: Time-to-live for the transactionOptions
forceLargestFirstSelection
: Always use largest-first algorithmdebug
: print debug information about coin-selection (selected utxos, outputs including change output,...)
export const utxo1 = {
address:
'addr1q860vxljhadqxnrrsr2j6yxnwpdkyquq74lmghx502aj0r28d2kd47hsre5v9urjyu8s0ryk38dxzw0t5jesncw4v90sp0878u',
txHash: '3c388acb799a37a4f1cc99bec7626637b0b80626b9ef7c7a687282cab701178d',
outputIndex: 0,
amount: [
{
quantity: '5000000',
unit: 'lovelace',
},
],
};
export const utxo2 = {
address:
'addr1q860vxljhadqxnrrsr2j6yxnwpdkyquq74lmghx502aj0r28d2kd47hsre5v9urjyu8s0ryk38dxzw0t5jesncw4v90sp0878u',
txHash: '9e63fddf20cb7b5472e2c9a1bb4bbe3112b8f2b22e45bc441206bcddde5c58a0',
outputIndex: 1,
amount: [
{
quantity: '5000000',
unit: 'lovelace',
},
{
quantity: '1000',
unit: '02477d7c23b4c2834b0be8ca8578dde47af0cc82a964688f6fc95a7a47524943',
},
],
};
const txPlan = coinSelection(
txParams: {
utxos: Utxo[];
outputs: [
{
address:
'addr1qya0nkzrf04gmcpu66vdt7sudwptnyg5df6475y7jhtt2wc44vzmgrfy6wwf69xlaszdslksw8evveyykw4c82eavq7sx29tlc',
amount: '1000000',
assets: [],
setMax: false,
},
{
address:
'addr1qya0nkzrf04gmcpu66vdt7sudwptnyg5df6475y7jhtt2wc44vzmgrfy6wwf69xlaszdslksw8evveyykw4c82eavq7sx29tlc',
amount: undefined,
assets: [],
setMax: true,
},
],
changeAddress: `addr1q8u2f05rprqjhygz22m06mhy4xrnqvqqpyuzhmxqfxnwvxz8d2kd47hsre5v9urjyu8s0ryk38dxzw0t5jesncw4v90s22tk0f`,
certificates: [],
withdrawals: [],
accountPubKey:
'ec8fdf616242f430855ad7477acda53395eb30c295f5a7ef038712578877375b5a2f00353c9c5cc88c7ff18e71dc08724d90fc238213b789c0b02438e336be07',
},
);
// txPlan
// {
// max: '7480901',
// totalSpent: '8655202',
// fee: '174301',
// inputs: [utxo1, utxo2],
// outputs: [
// {
// address:
// 'addr1qya0nkzrf04gmcpu66vdt7sudwptnyg5df6475y7jhtt2wc44vzmgrfy6wwf69xlaszdslksw8evveyykw4c82eavq7sx29tlc',
// amount: '1000000',
// assets: [],
// setMax: false,
// },
// {
// address:
// 'addr1qya0nkzrf04gmcpu66vdt7sudwptnyg5df6475y7jhtt2wc44vzmgrfy6wwf69xlaszdslksw8evveyykw4c82eavq7sx29tlc',
// amount: '7480901',
// assets: [],
// setMax: true,
// },
// {
// isChange: true,
// address: changeAddress,
// amount: '1344798',
// assets: [
// {
// quantity: '1000',
// unit: '02477d7c23b4c2834b0be8ca8578dde47af0cc82a964688f6fc95a7a47524943',
// },
// ],
// },
// ],
// },
;
const txPlan = coinSelection(
{
utxos: [utxo1];
outputs: [
{
address: undefined, // address not filled
amount: '2000000',
assets: [],
setMax: false,
},
],
changeAddress: `addr1q8u2f05rprqjhygz22m06mhy4xrnqvqqpyuzhmxqfxnwvxz8d2kd47hsre5v9urjyu8s0ryk38dxzw0t5jesncw4v90s22tk0f`,
certificates: [],
withdrawals: [],
accountPubKey:
'ec8fdf616242f430855ad7477acda53395eb30c295f5a7ef038712578877375b5a2f00353c9c5cc88c7ff18e71dc08724d90fc238213b789c0b02438e336be07',
},
);
// txPlan:
// {
// totalSpent: '2168053',
// fee: '168053',
// },
setMax: true
then largest-first algorithm will be used instead of random-improve.FAQs
Unknown package
We found that @onekeyfe/cardano-coin-selection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.