Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.

Commit 21ce3ef

Browse files
authored
Merge pull request #78 from pollastri-pierre/fix/rbf
Add bindings for BitcoinLikeOutput::isReplaceable()
2 parents a9e03be + 64dcc7a commit 21ce3ef

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

include/BitcoinLikeOutput.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ class LIBCORE_EXPORT BitcoinLikeOutput {
6363
virtual std::shared_ptr<DerivationPath> getDerivationPath() = 0;
6464

6565
virtual std::experimental::optional<int64_t> getBlockHeight() = 0;
66+
67+
/**
68+
* Check if the transaction (which created this output) is replaceable (RBF).
69+
* An output can be replaceable if the transaction has at least one RBF input
70+
* and if the transaction is not a block.
71+
* @return true if the output is replaceable, false otherwise
72+
*/
73+
virtual bool isReplaceable() const = 0;
6674
};
6775

6876
} } } // namespace ledger::core::api

include/CosmosConfigurationDefaults.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ledger { namespace core { namespace api {
77

8-
std::string const CosmosConfigurationDefaults::COSMOS_DEFAULT_API_ENDPOINT = {"http://lite-client-0e27eefb-4031-4859-a88e-249fd241989d.cosmos.bison.run:1317"};
8+
std::string const CosmosConfigurationDefaults::COSMOS_DEFAULT_API_ENDPOINT = {"https://cosmos.coin.staging.aws.ledger.com"};
99

1010
std::string const CosmosConfigurationDefaults::COSMOS_OBSERVER_WS_ENDPOINT = {""};
1111

src/NJSBitcoinLikeOutputCpp.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,31 @@ NAN_METHOD(NJSBitcoinLikeOutput::getBlockHeight) {
225225
}
226226

227227

228+
//Return result
229+
info.GetReturnValue().Set(arg_0);
230+
}
231+
NAN_METHOD(NJSBitcoinLikeOutput::isReplaceable) {
232+
233+
//Check if method called with right number of arguments
234+
if(info.Length() != 0)
235+
{
236+
return Nan::ThrowError("NJSBitcoinLikeOutput::isReplaceable needs 0 arguments");
237+
}
238+
239+
//Check if parameters have correct types
240+
241+
//Unwrap current object and retrieve its Cpp Implementation
242+
auto cpp_impl = djinni::js::ObjectWrapper<ledger::core::api::BitcoinLikeOutput>::Unwrap(info.This());
243+
if(!cpp_impl)
244+
{
245+
return Nan::ThrowError("NJSBitcoinLikeOutput::isReplaceable : implementation of BitcoinLikeOutput is not valid");
246+
}
247+
248+
auto result = cpp_impl->isReplaceable();
249+
250+
//Wrap result in node object
251+
auto arg_0 = Nan::New<Boolean>(result);
252+
228253
//Return result
229254
info.GetReturnValue().Set(arg_0);
230255
}
@@ -282,6 +307,7 @@ void NJSBitcoinLikeOutput::Initialize(Local<Object> target) {
282307
Nan::SetPrototypeMethod(func_template,"getAddress", getAddress);
283308
Nan::SetPrototypeMethod(func_template,"getDerivationPath", getDerivationPath);
284309
Nan::SetPrototypeMethod(func_template,"getBlockHeight", getBlockHeight);
310+
Nan::SetPrototypeMethod(func_template,"isReplaceable", isReplaceable);
285311
Nan::SetPrototypeMethod(func_template,"isNull", isNull);
286312
//Set object prototype
287313
BitcoinLikeOutput_prototype.Reset(objectTemplate);

src/NJSBitcoinLikeOutputCpp.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ class NJSBitcoinLikeOutput final {
6969

7070
static NAN_METHOD(getBlockHeight);
7171

72+
/**
73+
* Check if the transaction (which created this output) is replaceable (RBF).
74+
* An output can be replaceable if the transaction has at least one RBF input
75+
* and if the transaction is not a block.
76+
* @return true if the output is replaceable, false otherwise
77+
*/
78+
static NAN_METHOD(isReplaceable);
79+
7280
static NAN_METHOD(New);
7381

7482
static NAN_METHOD(isNull);

src/ledgercore_doc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,6 +3261,13 @@ declare class NJSBitcoinLikeOutput
32613261
declare function getAddress(): ?string;
32623262
declare function getDerivationPath(): ?NJSDerivationPath;
32633263
declare function getBlockHeight(): ?number;
3264+
/**
3265+
* Check if the transaction (which created this output) is replaceable (RBF).
3266+
* An output can be replaceable if the transaction has at least one RBF input
3267+
* and if the transaction is not a block.
3268+
* @return true if the output is replaceable, false otherwise
3269+
*/
3270+
declare function isReplaceable(): boolean;
32643271
}
32653272
/** Class representing Bitcoin block */
32663273
declare class NJSBitcoinLikeBlock

0 commit comments

Comments
 (0)