Skip to content

Conversation

@lissavxo
Copy link
Collaborator

@lissavxo lissavxo commented Jan 12, 2025

Related to #916

Description

Send input addresses in broadcast incoming tx data, this will be used in paybutton client, this will make input addresses available on client callbacks

Test plan

  • Run server with docker compose up
  • Run client in this PR feat: add inputs to tx type paybutton#445
  • Test if inputs are being returned as a param (inputAddresses) of tx object in onSuccess/OnTransaction callbacks

console.log(`${this.CHRONIK_MSG_PREFIX}: [${msg.msgType}] ${msg.txid}`)
const transaction = await this.chronik.tx(msg.txid)
const addressesWithTransactions = await this.getAddressesForTransaction(transaction)
const inputAddresses = transaction.inputs.map(inp => outputScriptToAddress(this.networkSlug, inp.outputScript))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we sort this by amount contributed by each address?

Also, if 2 or more inputs use the same address, does this already consolidate them to only show them in the addressInput list once?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserves some tests.

@lissavxo lissavxo requested a review from Klakurka January 13, 2025 15:35
timestamp: number
address: string
rawMessage: string
inputAddresses?: Array<string | undefined>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this typing (here and in the other parts of this PR where this same type appears): Array<string | undefined> . The function you created, getInputAddresses, returns string[], so why this undefined?

}
}

private getInputAddresses (transaction: Tx_InNode): string[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call this getSortedInputAddresses since is does that

}
for (const transaction of blockTxsToSync) {
const addressesWithTransactions = await this.getAddressesForTransaction(transaction)
const inputAddresses = transaction.inputs.map(inp => outputScriptToAddress(this.networkSlug, inp.outputScript))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the function you created here? Why sorted input addresses elsewhere but not here?

@Klakurka
Copy link
Member

Tested and it works as expected (checked a few edge cases just to be sure) but I'll wait to approve until @chedieck has done so.

chedieck
chedieck previously approved these changes Jan 16, 2025
@Klakurka
Copy link
Member

Conflicts.

@lissavxo
Copy link
Collaborator Author

resolved

@chedieck chedieck merged commit 9d8ed19 into master Jan 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants