fix: pay transaction fees from system accounts

This commit is contained in:
Michael Vines
2019-05-08 09:33:04 -07:00
parent 7bde7e3767
commit 48f0bcc2bf
10 changed files with 133 additions and 166 deletions

View File

@@ -92,7 +92,7 @@ export class Transaction {
signatures: Array<SignaturePubkeyPair> = [];
/**
* The first (primary) Transaction signature
* The first (payer) Transaction signature
*/
get signature(): Buffer | null {
if (this.signatures.length > 0) {
@@ -172,6 +172,14 @@ export class Transaction {
});
});
if (numRequiredSignatures > this.signatures.length) {
throw new Error(
`Insufficent signatures: expected ${numRequiredSignatures} but got ${
this.signatures.length
}`,
);
}
let keyCount = [];
shortvec.encodeLength(keyCount, keys.length);
@@ -252,7 +260,7 @@ export class Transaction {
]);
const transaction = {
numRequiredSignatures: Buffer.from([numRequiredSignatures]),
numRequiredSignatures: Buffer.from([this.signatures.length]),
keyCount: Buffer.from(keyCount),
keys: keys.map(key => new PublicKey(key).toBuffer()),
recentBlockhash: Buffer.from(bs58.decode(recentBlockhash)),