Comments (5)
You can sign a message w/ a key and then take the resulting signature and recover the address from the message and signature.
Check out this gist
ts-node sign-message-and-recover-address.ts
Address: X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u
Message: From snowflake to Avalanche
Signature: Df5bvmWnqRYSpWBbJX3KNPnKNgWhoefSjQ6ZbB7hNiH8xzmJcssaeEFwotwfwC8FvriJUfueHfULXdouFq9sAbFwmJ1S5U
--------------------------
Recovering address from message and signature...
Address: X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u
You should be able to do something similar where the serialized transaction is the message.
from avalanchejs.
This doesn't solve my problem. I don't have the message nor the signature, so I can't recover the public key (so the address)
Message that signed is the transaction which input refers to. If I send another query just to get the previous tx (message that signed) I can also get address from outputs. No point for address recovery.
I am looking for a way to use Avalanchejs for this.
As I understand Avalanche transactions doesn't have public key info in inputs, so no possibility to get address from inputs (w/o sending another query to the node)
from avalanchejs.
Reopening
from avalanchejs.
GetTxByID
isn't a method on AvalancheJS. Can you provide any more details? I'm guessing you mean getTx
.
@farukterzioglu can you provide a gist of what you're doing?
from avalanchejs.
while you have the UnsignedTx
object,
you can serialize it to find a breakdown of the transaction
let serialized: any = unsignedTx.serialize("display")
console.log(JSON.stringify(serialized))
you would get something that looks like the following.
{
"_typeName": "Tx",
"_typeID": null,
"_codecID": null,
"unsignedTx": {
"_typeName": "UnsignedTx",
"_typeID": null,
"_codecID": null,
"codecID": "0",
"transaction": {
"_typeName": "ExportTx",
"_typeID": 4,
"_codecID": 0,
"networkID": "12345",
"blockchainID": "2eNy1mUFdmaxXNj1eQHUe7Np4gju9sJsEtWQ4MX3ToiNKuADed",
"outs": [],
"ins": [
{
"_typeName": "TransferableInput",
"_typeID": null,
"_codecID": null,
"input": {
"_typeName": "SECPTransferInput",
"_typeID": 5,
"_codecID": 0,
"sigIdxs": [
{
"_typeName": "SigIdx",
"_typeID": null,
"_codecID": null,
"bsize": "4",
"bytes": "00000000",
"source": "3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c"
}
],
"amount": "300000000000000000"
},
"txid": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
"outputidx": "1",
"assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
}
],
"memo": "41564d207574696c697479206d6574686f64206275696c644578706f7274547820746f206578706f7274204156415820746f2074686520502d436861696e2066726f6d2074686520582d436861696e",
"destinationChain": "11111111111111111111111111111111LpoYY",
"exportOuts": [
{
"_typeName": "TransferableOutput",
"_typeID": null,
"_codecID": null,
"output": {
"_typeName": "SECPTransferOutput",
"_typeID": 7,
"_codecID": 0,
"locktime": "0",
"threshold": "1",
"addresses": [
{
"_typeName": "Address",
"_typeID": null,
"_codecID": null,
"bsize": "20",
"bytes": "3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c"
}
],
"amount": "299999999999000000"
},
"assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
}
]
}
},
"credentials": [
{
"_typeName": "SECPCredential",
"_typeID": 9,
"_codecID": 0,
"sigArray": [
{
"_typeName": "Signature",
"_typeID": null,
"_codecID": null,
"bsize": "65",
"bytes": "34fee7c44a85bfcd7c7ae92d5b0d37f40e2bfb85126b7d1edb966470407daa020bd64395a3d4d3dea9f210a85c27acec85f261423b4c1f79c0fc7afce2d99f9101"
}
]
}
]
}
If what you're looking for is not in there, then you'd need to use Ortelius
https://docs.avax.network/build/tools/ortelius
Closing due to inactivity and age, but we can reopen if the above doesn't help.
from avalanchejs.
Related Issues (20)
- feature request: Banff Update Support
- getPreferredHRP returns incorrect prefix HOT 1
- Defaults.network[networkID].C.blockchainID returns incorrect Blockchain ID
- AvalancheCore.post request is not working with URL of format https://username:[email protected]
- How to get pending transactions HOT 1
- getAtomicTx method does not return the block height
- Pchain getBalance doesn't work
- Missing @avalabs/avalanchejs on yarn package manager
- X-Chain getting UTXO set example uses wrong variable!
- unable to parse block in js
- how to parse block in js
- getContainerByIndex problem with 3.17.0
- Decoding atomic transaction from byte data returned by `getAtomicTx` rpc call HOT 1
- Security: insecure deps are used, switch to better ones HOT 2
- Cannot use v3.18.1 for addPermissionlessValidator and addPermissionlessDelegator Transactions
- Export C-to-X example does not work HOT 3
- exec delegate.ts issue
- Add support for AddPermissionlessValidator and AddPermissionlessDelegator transactions in v3
- Support for Node18 HOT 2
- facing issue of invalid signature when sending delegate transaction. (Error: couldn't issue tx: flow check failed: failed to verify transfer: invalid signature)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalanchejs.