Skip to content

Commit c585fad

Browse files
author
Po
committed
change decode endpoint to POST
1 parent 067965c commit c585fad

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

WalletProxy/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ http://127.0.0.1:9009/block/count
3131
http://127.0.0.1:9009/block/{index:long}
3232
http://127.0.0.1:9009/block/hash/{hash}
3333
http://127.0.0.1:9009/transaction/raw/{txId}
34-
http://127.0.0.1:9009/transaction/decode/{transaction}
34+
35+
36+
POST http://127.0.0.1:9009/transaction/raw/decode {rawtransaction:string}
3537
3638
create a raw coinstake transaction:
3739
POST http://127.0.0.1:9009/transaction/raw/coinstake

WalletProxy/src/app.controller.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,30 @@ export class AppController {
4242

4343
@Get("transaction/raw/:txId")
4444
async getRawTransaction(@Param("txId") txId: string): Promise<any> {
45-
console.log('getRawTransaction')
45+
//console.log('getRawTransaction')
4646
return await this.appService.getRawTransaction(txId, 0);
4747
}
4848

49-
@Get("transaction/decode/:transaction ")
50-
async getaRawTransaction(
51-
@Param("transaction") transaction: string
49+
@Post("transaction/raw/decode")
50+
async decodeRawTransaction(
51+
//@Res() response,
52+
@Body()
53+
message: {
54+
rawtransaction: string;
55+
}
5256
): Promise<any> {
53-
return await this.appService.decodeRawTransaction(transaction);
57+
//console.log(message.rawtransaction);
58+
let transaction = await this.appService.decodeRawTransaction(
59+
message.rawtransaction
60+
);
61+
62+
//console.log(transaction);
63+
return transaction;
5464
}
5565

5666
@Post("transaction/raw/coinstake")
5767
async createMessage(
58-
@Res() response,
68+
//@Res() response,
5969
@Body()
6070
message: {
6171
txid: string;
@@ -67,21 +77,17 @@ export class AppController {
6777
minterPubkey: string;
6878
}
6979
) {
70-
try {
71-
console.log(message);
72-
return await this.appService.createRawCoinstakeTransaction(
73-
message.txid,
74-
Number(message.vout),
75-
message.redeemScript,
76-
message.address,
77-
Number(message.futureOutput),
78-
Number(message.futureTimestamp),
79-
message.minterPubkey
80-
);
81-
82-
} catch (error) {
83-
console.warn(error);
84-
return response.status(400);
85-
}
80+
console.log(message);
81+
const response = await this.appService.createRawCoinstakeTransaction(
82+
message.txid,
83+
Number(message.vout),
84+
message.redeemScript,
85+
message.address,
86+
Number(message.futureOutput),
87+
Number(message.futureTimestamp),
88+
message.minterPubkey
89+
);
90+
console.log(response);
91+
return response;
8692
}
8793
}

0 commit comments

Comments
 (0)